-
Notifications
You must be signed in to change notification settings - Fork 1
log.level
Grant Carthew edited this page Oct 25, 2024
·
4 revisions
Type: Property
Read / Write
Set: Assign a string log level name.
log.level = 'debug'
Get: Returns the current logging level string name.
const currentLevel = log.level
Example:
const log = new Perj(options)
if (log.level === 'info') {
log.level = 'debug'
}
The log.level
property enables you to see the current logging level of the logger object and set the logging level of the logger object.
One way you can use this option is to turn up the logging level for a module you are trying to debug by using a log.child logger. Set the logging level on the child to something like 'trace' while the other loggers in your application are set to 'warn'.
See the level and levels option documents for more detail.
Here is a simple example of using the log.level
property:
import Perj from 'perj'
const log = new Perj()
console.log(log.level)
// console output: 'info'
log.info('information')
// stdout: {"level":"info","lvl":30,"time":1526276932034,"msg":"information","data":""}
log.level = 'warn'
// logging level changed to 'warn'
log.info('information')
// no output