Skip to content
Grant Carthew edited this page May 12, 2018 · 13 revisions

perj levels Option

Type: Object

Default:

{
    fatal: 60,
    error: 50,
    warn: 40,
    info: 30,
    debug: 20,
    trace: 10
}

Valid: Object with keys set to Number values.

Description:

The levels option object is used to build the logger level functions. The key values, such as 'trace' become the function names. The Number value is used in conjunction with the level option.

Once the levels have been applied to the log object, you can call each level like so: log.warn('Don't do that!')

Example:

This example changes the levels significantly:

const perj = require('perj')
const levels = { silly: 100, crazy: 200, nuts: 300 }
const log = perj.create({ levels, level: 'silly' })

log.silly('This is a very silly log entry')
log.crazy('This log entry is just looney!')
log.nuts('And this one is a few screws loose')

// Standard out:
// {"level":"silly","lvl":100,"time":1525495702926,"msg":"This is a very silly log entry","data":""}
// {"level":"crazy","lvl":200,"time":1525495702930,"msg":"This log entry is just looney!","data":""}
// {"level":"nuts","lvl":300,"time":1525495702934,"msg":"And this one is a few screws loose","data":""}