Add logger for application lifecycle

This commit is contained in:
Amir Husayn Panahifar 2025-04-08 02:49:14 +03:30
parent 0c760dc303
commit 23ad99910f

32
src/utils/logger.js Normal file
View file

@ -0,0 +1,32 @@
import winston from "winston";
const logger = () => {
try {
return winston.createLogger({
level: 'info',
format: winston.format.combine(
winston.format.colorize(),
winston.format.simple()
),
transports: [
new winston.transports.Console(),
new winston.transports.File({
filename: 'logs/bot.log',
options: { flags: 'a' },
level: 'info',
async: true
})
]
});
} catch (error) {
console.error('Logger creation failed:', error);
}
};
const log = logger();
if (log) {
log.info('Bot started');
}
export { log };