src/logger.js   A
last analyzed

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 37
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 25
mnd 0
bc 0
fnc 1
dl 0
loc 37
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
rs 10
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