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

perj levelKey Option

The levelKey option enables you to change the JSON key used for the level output.

Type: String

Default: level

Valid: Any String

Description:

The levelKey option is used to change the key used in the output JSON for the level value. For example, the default levelKey of 'level' will produce an output from the logger of:

{"level": "info",...

If you set the levelKey options to 'log_level' then the output from the logger would look like:

{"log_level": "info",...

Example

This example changes the levelKey from the default of 'level' to 'log_level':

import Perj from 'perj'
const log = new Perj({ levelKey: 'log_level' })

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

/*

Standard out will be:

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

*/