-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathlogger.js
More file actions
27 lines (22 loc) · 798 Bytes
/
logger.js
File metadata and controls
27 lines (22 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const winston = require('winston');
const config = require('config');
const colorizer = winston.format.colorize();
const createConsoleLogger = () => {
// eslint-disable-next-line new-cap
const logger = new winston.createLogger({
exitOnError: false,
level: config.isDev ? 'debug' : 'info',
format: winston.format.combine(
winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }),
config.isDev
? winston.format.printf((msg) => colorizer.colorize(msg.level, `${msg.timestamp} - ${msg.level}: ${JSON.stringify(msg.message)}`))
: winston.format.json(),
),
transports: [
new winston.transports.Console(),
],
});
logger.debug('[logger] Configured console based logger');
return logger;
};
module.exports = createConsoleLogger();