-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.js
More file actions
23 lines (19 loc) · 785 Bytes
/
Copy pathlogger.js
File metadata and controls
23 lines (19 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const winston = require('winston');
const logger = winston.createLogger({
level: 'info',
format: winston.format.json(),
// defaultMeta: { service: 'user-service' },
transports: [
new winston.transports.File({ filename: 'logs/error.log', level: 'error', colorize: true, }),
new winston.transports.File({ filename: 'logs/info.log', level: 'info', colorize: true, }),
// new winston.transports.Console({ format: winston.format.simple(), colorize: true, }),
]
});
/**
* @description If it's not an production environment do logs on console
*/
if (process.env.NODE_ENV !== 'production') {
logger.add(new winston.transports.Console({ format: winston.format.simple() }));
}
logger.info(`Winston setup complete!`);
module.exports = logger;