BinCode/utils/logger.js

26 lines
573 B
JavaScript
Raw Permalink Normal View History

2025-01-17 20:05:21 +00:00
const winston = require('winston');
const logger = winston.createLogger({
level: process.env.LOG_LEVEL || 'info',
format: winston.format.combine(
winston.format.timestamp(),
winston.format.json()
),
transports: [
new winston.transports.Console({
format: winston.format.simple()
})
]
});
if (process.env.NODE_ENV === 'production') {
logger.add(new winston.transports.File({
filename: 'error.log',
level: 'error'
}));
logger.add(new winston.transports.File({
filename: 'combined.log'
}));
}
module.exports = logger;