Commit | Line | Data |
---|---|---|
3f40bc9c JB |
1 | import Configuration from './Configuration.js'; |
2 | import Winston from 'winston'; | |
7dde0b73 JB |
3 | |
4 | const logger = Winston.createLogger({ | |
2e6f5966 | 5 | level: Configuration.getLogLevel(), |
027b409a | 6 | format: Winston.format.combine(Winston.format.splat(), Winston.format[Configuration.getLogFormat()]()), |
7dde0b73 JB |
7 | transports: [ |
8 | // | |
9 | // - Write to all logs with level `info` and below to `combined.log` | |
10 | // - Write all logs error (and below) to `error.log`. | |
11 | // | |
12 | new Winston.transports.File({filename: Configuration.getErrorFile(), level: 'error'}), | |
13 | new Winston.transports.File({filename: Configuration.getLogFile()}), | |
14 | ], | |
15 | }); | |
16 | ||
17 | // | |
18 | // If enabled, log to the `console` with the format: | |
19 | // `${info.level}: ${info.message} JSON.stringify({ ...rest }) ` | |
20 | // | |
21 | if (Configuration.getConsoleLog()) { | |
22 | logger.add(new Winston.transports.Console({ | |
027b409a | 23 | format: Winston.format.combine(Winston.format.splat(), Winston.format[Configuration.getLogFormat()]()), |
7dde0b73 JB |
24 | })); |
25 | } | |
26 | ||
3f40bc9c | 27 | export default logger; |