-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.js
More file actions
42 lines (38 loc) · 911 Bytes
/
Copy pathlogger.js
File metadata and controls
42 lines (38 loc) · 911 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const _ = require('lodash');
const pino = require('pino');
let loggerConfig = {
dest: null,
app: null,
};
module.exports = (name, config) => {
const vConfig = _.merge({
dest: null,
respectAppDebug: true,
}, config);
let pinoDestination = undefined;
if (vConfig.dest) {
pinoDestination = pino.destination(vConfig.dest);
} else if (loggerConfig.dest) {
pinoDestination = pino.destination(loggerConfig.dest);
}
const ret = pino({
name,
prettyPrint: {
translateTime: 'SYS:standard',
},
...(pinoDestination ? {
prettyPrint: false,
} : {}),
}, pinoDestination);
ret.debug = true;
if (vConfig.respectAppDebug) {
if (loggerConfig.app && !loggerConfig.app.debug) {
ret.debug = false;
}
}
return ret;
};
module.exports.init = (config = {}) => {
const vConfig = _.merge({}, loggerConfig, config);
loggerConfig = vConfig;
};