-
Notifications
You must be signed in to change notification settings - Fork 1
level
Grant Carthew edited this page May 13, 2018
·
8 revisions
The perj
level option enables you to set the logging level.
{
fatal: 60,
error: 50,
warn: 40,
info: 30,
debug: 20,
trace: 10
}
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!')
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":""}
Note: In the above example, the log
object will only have a silly
, crazy
, and nuts
log functions. The default levels such as info
do not get created.