-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLOG.js
56 lines (47 loc) · 1.34 KB
/
LOG.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
45
46
47
48
49
50
51
52
53
54
55
56
const { createLogger, format, transports } = require('winston');
const { combine, timestamp, label, printf } = format;
const myFormat = printf(({ level, message, label, timestamp }) => {
return `${timestamp} [${label}] ${level}: ${message}`;
});
const myShortFormat = printf(({ level, message, label, timestamp }) => {
return `${timestamp} ${message}`;
});
//const logger = createLogger({
exports.createLogger = function (filename,loggerid) {
return createLogger({
level: 'info',
format: format.combine(
//format.timestamp({
// format: 'YYYY-MM-DD HH:mm:ss'
//}),
//format.errors({ stack: true }),
//format.splat(),
//format.json(),
//format.prettyPrint(),
label({ label: 'right meow!' }),
format.timestamp({
format: 'HH:mm:ss.SSSS'
}),
myShortFormat
),
defaultMeta: { service: loggerid },
transports: [
//
// - Write all logs to filename
//
new transports.File({ filename: "modules/MMM-FeedUtilities/logs/"+filename, options: { flags: 'w' } })
]
});
//
// If we're not in production then **ALSO** log to the `console`
// with the colorized simple format.
//
if (process.env.NODE_ENV !== 'production') {
logger.add(new transports.Console({
format: format.combine(
format.colorize(),
format.simple()
)
}));
}
};