summaryrefslogtreecommitdiff
path: root/lib/logging.js
blob: bca6eb61cc92c2dc47c84a0e62ec3447e9fbf874 (plain)
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
const log4js = require('log4js')

module.exports = {
    configure(verbose) {
        const categories = {
            default: {
                appenders: ['stdout-filter'],
                level: 'trace'
            }
        }
        const appenders = {
            stdout: {
                type: 'stdout',
                level: 'warn'
            },
            'stdout-filter': {
                type: 'logLevelFilter',
                appender: 'stdout',
                level: verbose ? 'debug' : 'warn'
            }
        }
        log4js.configure({
            appenders,
            categories
        })
    },

    getLogger(...args) {
        return log4js.getLogger(...args)
    },

    shutdown(cb) {
        log4js.shutdown(cb)
    }
}