-
Notifications
You must be signed in to change notification settings - Fork 1
levels
Grant Carthew edited this page May 12, 2018
·
13 revisions
{
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!')
The following table gives a summary of the levels and when to use them:
level | lvl | When to Use |
---|---|---|
fatal |
60 | Stop errors. Process crash. |
error |
50 | Processing failed for a known or unknown reason. |
warn |
40 | Something went wrong however it is not critical. |
info |
30 | Hey Dad? I dug a hole! (see The Castle). |
debug |
20 | When you need to find out where something happened. |
trace |
10 | When you need to know everything that happens. |
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":""}