You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
595 B
23 lines
595 B
let winston = require('winston');
|
|
|
|
let logger = winston.createLogger({
|
|
level: 'info',
|
|
format: winston.format.json(),
|
|
defaultMeta: { service: 'user-service' },
|
|
transports: [
|
|
new winston.transports.File({ filename: 'error.log', level: 'error' }),
|
|
new winston.transports.File({ filename: 'combined.log' })
|
|
]
|
|
});
|
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
logger.add(new winston.transports.Console({
|
|
format: winston.format.simple()
|
|
}));
|
|
}
|
|
|
|
if (process.env.LOG_LEVEL !== '') {
|
|
logger.level = process.env.LOG_LEVEL
|
|
}
|
|
|
|
exports.logger = logger;
|