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

Method Signature

log.addLevel(levels)

Type: Function

Parameter: levels Object with one or more key / value pairs.

Returns: undefined

Example:

import Perj from 'perj'
const log = new Perj(options)
log.addLevel({ extreme: 1 })

Description

Use the log.addLevel function to add to the existing levels on the logger object.

See the levels document for more detail.

Examples

Adding an extreme level to a logger object:

import Perj from 'perj'
const log = new Perj()

log.addLevel({ extreme: 1 })

console.dir(log.levels)
/*
{
  fatal: 60,
  error: 50,
  warn: 40,
  info: 30,
  debug: 20,
  trace: 10,
  extreme: 1
}
*/

log.level = 'extreme'
log.extreme('vrooooom....')
// {"level":"extreme","lvl":1,"time":1526278553689,"msg":"vrooooom....","data":""}