Skip to content

levelNumberKeyEnabled

Grant Carthew edited this page Oct 25, 2024 · 7 revisions

perj levelNumberKeyEnabled Option

The levelNumberKeyEnabled option turns on the levelNumberKey in the JSON output.

Type: Boolean

Default: true

Valid: true or false

Description:

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

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

If you set the levelNumberKeyEnabled 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 levelNumberKeyEnabled from the default value of 'true' to 'false':

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

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

/*

Standard out will be:

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

*/