mirror of
https://github.com/log4js-node/log4js-node.git
synced 2025-12-08 19:26:01 +00:00
test: Add typescript recording usage example
This commit is contained in:
parent
5b320e3b2f
commit
c5ea84764d
@ -136,3 +136,25 @@ log4js.configure({
|
||||
appenders: { thing: { type: { configure: () => {} }}},
|
||||
categories: { default: { appenders: ['thing'], level: 'debug'}}
|
||||
});
|
||||
|
||||
log4js.configure({
|
||||
appenders: { rec: { type: 'recording' } },
|
||||
categories: { default: { appenders: [ 'rec'], 'level': 'debug' } }
|
||||
});
|
||||
const logger8 = log4js.getLogger();
|
||||
logger8.level = 'debug'
|
||||
logger8.debug('This will go to the recording!')
|
||||
logger8.debug('Another one')
|
||||
const recording = log4js.recording()
|
||||
const loggingEvents = recording.playback()
|
||||
if (loggingEvents.length !== 2) {
|
||||
throw new Error(`Expected 2 recorded events, got ${loggingEvents.length}`)
|
||||
}
|
||||
if (loggingEvents[1].data[0] !== 'Another one') {
|
||||
throw new Error(`Expected message 'Another one', got ${loggingEvents[1].data[0]}`)
|
||||
}
|
||||
recording.reset()
|
||||
const loggingEventsPostReset = recording.playback()
|
||||
if (loggingEventsPostReset.length !== 0) {
|
||||
throw new Error(`Expected 0 recorded events after reset, got ${loggingEventsPostReset.length}`)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user