Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardozgz committed Jan 13, 2025
1 parent bdf66fb commit a234778
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions apps/bot/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import { env } from "./env";

async function main() {
const logger = baseLogger.child({
botId: env.DISCORD_BOT_INSTANCE_ID,
botChildId: env.DISCORD_BOT_INSTANCE_CHILD_ID,
source: `bot: ${env.DISCORD_BOT_INSTANCE_ID} (${env.DISCORD_BOT_INSTANCE_CHILD_ID})`,
});

const botOptions: BotInstanceOptions = {
Expand Down
5 changes: 2 additions & 3 deletions packages/logger/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const logger = winston.createLogger({
winston.format.splat(),
winston.format.timestamp(),
winston.format.printf(
({ level, message, timestamp, botId, botChildId, ...metadata }) => {
({ level, message, timestamp, source, ...metadata }) => {
const metadataStr = Object.keys(metadata).length
? "metadata: " + inspect(metadata)
: null;
Expand All @@ -40,9 +40,8 @@ const logger = winston.createLogger({
: null;

const messageStr = `${level}: ${message}`;
const botIdStr = botId ? `bot: ${botId} (${botChildId})` : null;

return [timestamp, botIdStr, messageStr, metadataStr, metadataJSONStr]
return [timestamp, source, messageStr, metadataStr, metadataJSONStr]
.filter(Boolean)
.join(" - ");
},
Expand Down

0 comments on commit a234778

Please sign in to comment.