-
Notifications
You must be signed in to change notification settings - Fork 1
log.parent
Grant Carthew edited this page Oct 25, 2024
·
7 revisions
Type: Property
Read Only
Get: Returns the parent logger object.
const parent = log.parent
Example:
import Perj from 'perj'
const log = new Perj(options)
const child = log.child({ sessionId: '1234' })
child.parent.info('parent logging here!')
When using log.child to create a child logger, the new child logger will have a log.parent
property set to the value of the parent logger object. This is a convenience property to help you access the parent logger.
Here is a simple example of using the log.parent
property:
import Perj from 'perj'
const log = new Perj(options)
const child = log.child({ sessionId: '1234' })
child.parent.info('parent logging here!')
// Notice there is no 'sessionId' key
// output: {"level":"info","lvl":30,"time":1526279764200,"msg":"parent logging here!","data":""}