-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlogger.js
44 lines (37 loc) · 1.32 KB
/
logger.js
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Setting up the logger for the project
// -> console & file
const winston = require('winston');
const path = require('path');
const filename = path.join(process.cwd()+'/Logs/', 'created-logfile.log');
const logger = module.exports = winston.createLogger({
format: winston.format.combine(
winston.format.splat(),
winston.format.timestamp({
format: 'YY-MM-DD HH:mm:ss'
}),
//
// The simple format outputs
// `${level}: ${message} ${[Object with everything else]}`
//
// winston.format.simple()
//
// Alternatively you could use this custom printf format if you
// want to control where the timestamp comes in your final message.
// Try replacing `format.simple()` above with this:
//
winston.format.printf(info => `${info.timestamp} ${info.level}: ${info.message}`)
),
transports: [
new winston.transports.Console({
format: winston.format.combine(
winston.format.splat(),
winston.format.timestamp(),
winston.format.colorize(),
winston.format.printf(info => `${info.timestamp} ${info.level}: ${info.message}`)
)
}),
new winston.transports.File({ filename }
)
]
});
module.exports = logger;