Total Complexity | 1 |
Complexity/F | 1 |
Lines of Code | 37 |
Function Count | 1 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | /* eslint-disable camelcase */ |
||
2 | import { createLogger, format, transports } from 'winston'; |
||
3 | import { version, name } from '../package.json'; |
||
4 | |||
5 | const appNameFormat = format(info => { |
||
6 | info[name] = version; // eslint-disable-line no-param-reassign |
||
7 | |||
8 | return info; |
||
9 | }); |
||
10 | |||
11 | const { npm_config_loglevel, ATLASSIAN_DEBUG, ATLASSIAN_LOG_LEVEL } = process.env; |
||
12 | |||
13 | export const level = ATLASSIAN_LOG_LEVEL || ATLASSIAN_DEBUG && 'debug' || npm_config_loglevel || 'notice'; |
||
14 | export const levels = { |
||
15 | error : 0, |
||
16 | warn : 1, |
||
17 | info : 2, |
||
18 | notice : 3, |
||
19 | verbose : 4, |
||
20 | debug : 5 |
||
21 | }; |
||
22 | |||
23 | export const JSONFormats = [ |
||
24 | format.splat(), |
||
25 | appNameFormat(), |
||
26 | format.timestamp(), |
||
27 | format.json() |
||
28 | ]; |
||
29 | |||
30 | |||
31 | export default createLogger({ |
||
32 | level, |
||
33 | levels, |
||
34 | format : format.combine(...JSONFormats), |
||
35 | transports : [ |
||
36 | new transports.Console({}) |
||
37 | ] |
||
38 | }); |
||
39 |