-
Notifications
You must be signed in to change notification settings - Fork 2
/
logging.js
32 lines (27 loc) · 863 Bytes
/
logging.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
const winston = require('winston');
global.LOG = null;
// ---------- Shared state ----------
// global.CONFIG (see main.js)
function initialize() {
const tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
LOG = winston.createLogger({
level: CONFIG.options.logLevel,
format: winston.format.combine(
winston.format.splat(),
winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss', tz: tz }),
winston.format.printf(({level, message, timestamp}) => {
return `${timestamp} ${level}: ${message}`;
})
),
transports: [
new winston.transports.File({
filename: 'eltern-emailer.log',
maxsize: 10 << 20,
maxFiles: 2
}),
new winston.transports.Console()
]
});
LOG.debug(`Using timezone "${tz}"`);
}
module.exports = { initialize };