-
Notifications
You must be signed in to change notification settings - Fork 1
level
The level
option enables you to set the logging level.
Valid: One of the levels object keys.
A string key that matches one of the keys supplied with the levels option. The default level strings are 'fatal', 'error', 'warn', 'info', 'debug', and 'trace'. These can be completely customized using the levels option.
The level
option is used to determine the logging level. Setting this value to the logging levels key with the highest number, such as 'fatal', will prevent all log messages except 'fatal' messages. Setting it to the key with lowest number such as 'trace' will cause all log messages to be output. The default value of 'info' will cause the logger to output 'fatal', 'error', 'warn', and 'info' messages. The remaining 'debug' and 'trace' messages will be suppressed.
The level number such as 30
for the 'info' level, is sent with the log output under the lvl
key by default. See the levels document for more detail.
The logging level can be changed on an existing logger object by setting the log.level property. For example: log.level = 'debug'
Example:
This example sets the log level to 'error' causing only 'error' and 'fatal' log messages to be output:
import Perj from 'perj'
const log = new Perj({ level: 'error' })
log.info('This message will not be output by the logger.')
log.error('This message will be output by the logger.')
log.fatal('As will this one.')
// Standard out:
// {"level":"error","lvl":50,"time":1525643291716,"msg":"This message will be output by the logger.","data":""}
// {"level":"fatal","lvl":60,"time":1525643291721,"msg":"As will this one.","data":""}