Skip to content

Commit

Permalink
refactor: improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
bludnic committed May 19, 2024
1 parent 20b8c9b commit dba32ef
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/cli/src/api/run-trading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export async function runTrading(
`Bot "${bot.label}" is already enabled. Cancelling previous orders...`,
);
await stopBot(bot.id);
logger.info(`The bot state were cleared`);
logger.info(`The bot state was cleared`);
}

if (bot.processing) {
Expand Down
5 changes: 1 addition & 4 deletions packages/cli/src/utils/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ export function handle<T extends any[], U>(
logger.info(result);
}
} catch (error) {
console.error(
"Error:",
error instanceof Error ? error.message : "Unknown error",
);
console.error(error);
}
};
}
6 changes: 4 additions & 2 deletions packages/processing/src/bot/bot.processing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class BotProcessing {
market?: MarketData,
) {
console.log(
`🤖 Bot #${this.bot.id} command=${command} candle=${JSON.stringify(market?.candle)} candlesHistory=${market?.candles.length} start`,
`🤖 Processing "${command}" command. Context { candle=${JSON.stringify(market?.candle)}, candlesHistory=${market?.candles.length || 0} }. Bot { id: ${this.bot.id}, name: ${this.bot.name} }`,
);
if (this.isBotProcessing()) {
console.warn(
Expand All @@ -101,7 +101,9 @@ export class BotProcessing {
}

await xprisma.bot.setProcessing(false, this.bot.id);
console.log(`🤖 Bot #${this.bot.id} command=${command} finished`);
console.log(
`🤖 Processing "${command}" command finished. Bot { id: ${this.bot.id}, name: ${this.bot.name} }`,
);
}

async processStartCommand() {
Expand Down

0 comments on commit dba32ef

Please sign in to comment.