Skip to content

Commit

Permalink
move to the pino logger
Browse files Browse the repository at this point in the history
set minimum node version to 20.11.0
  • Loading branch information
AleX83Xpert committed Feb 6, 2024
1 parent 6c07740 commit 472f841
Show file tree
Hide file tree
Showing 3 changed files with 311 additions and 381 deletions.
31 changes: 5 additions & 26 deletions logger.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,8 @@
const { createLogger, format, transports } = require('winston');
const { combine, splat, timestamp, printf } = format;
const pino = require('pino')

const myFormat = printf(({ level, message, timestamp, ...metadata }) => {
let msg = `${timestamp} [${level}] : ${message} `
if (!!metadata) {
const metaStr = JSON.stringify(metadata)
if (metaStr !== '{}') {
msg += metaStr
}
}
return msg.trim()
});

const logger = createLogger({
level: 'debug',
format: combine(
format.colorize(),
splat(),
timestamp(),
myFormat
),
transports: [
new transports.Console(),
new transports.File({ filename: 'combined.log' }),
]
});
const logger = pino({
name: 'bot',
timestamp: () => `,"time":"${new Date(Date.now()).toISOString()}"`,
})

module.exports = logger
Loading

0 comments on commit 472f841

Please sign in to comment.