Skip to content
Grant Carthew edited this page Oct 25, 2024 · 6 revisions

perj levelKeyEnabled Option

The levelKeyEnabled option turns on the levelKey in the JSON output.

Type: Boolean

Default: true

Valid: true or false

Description:

The levelKeyEnabled option is used to enable or disable the "level" key in the JSON output. For example, setting the levelKeyEnabled option to false will produce an output from the logger of:

{"lvl":30,"time":1525643291716,"msg":"You have advanced to the next level!","data":""}

If you set the levelKeyEnabled options to 'true' or leave it at the default value, then the output from the logger would look like:

{"level":"info","lvl":30,"time":1525643291716,"msg":"You have advanced to the next level!","data":""}

Warning: Do not set both the levelKeyEnabled and the levelNumberKeyEnabled options to false or you will not be able to tell at what level the log output was made.

Example

This example changes the levelKeyEnabled from the default value of true to false:

import Perj from 'perj'
const log = new Perj({ levelKeyEnabled: false })

log.info('You have advanced to the next level!')

/*

Standard out will be:

{"lvl":30,"time":1525643291716,"msg":"You have advanced to the next level!","data":""}

*/