-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6131041
commit 4c3d4a3
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
'use strict' | ||
|
||
const { describe, it } = require('node:test') | ||
const assert = require('node:assert/strict') | ||
const { createLogger } = require('@xen-orchestra/log') | ||
const { configure } = require('@xen-orchestra/log/configure') | ||
// const { captureLogs } = require('@xen-orchestra/log/capture'); | ||
|
||
describe('capture log', () => { | ||
const logger = createLogger('test-logger') | ||
|
||
let messageStore | ||
const transportTest = message => { | ||
// console.log(`[transportTest] ${JSON.stringify(message)}`); | ||
// return message; | ||
messageStore = message | ||
} | ||
|
||
it('should define a test transport', () => { | ||
assert.notEqual(transportTest, undefined) | ||
}) | ||
it('should configure test transport', () => { | ||
assert.doesNotThrow(() => configure(transportTest)) | ||
}) | ||
it('should not throw', () => { | ||
assert.doesNotThrow(() => logger.debug('synchronous logs are captured')) | ||
}) | ||
it('should log test', () => { | ||
const expected = { | ||
data: undefined, | ||
level: 20, | ||
namespace: 'test-logger', | ||
message: 'synchronous logs are captured', | ||
time: new Date(), | ||
} | ||
logger.debug('synchronous logs are captured') | ||
assert.deepEqual(messageStore.time, expected.time) | ||
}) | ||
}) |