mirror of
https://github.com/zhigang1992/probot.git
synced 2026-06-14 18:08:58 +08:00
30 lines
761 B
TypeScript
30 lines
761 B
TypeScript
import { logger } from '../src/logger'
|
|
import { wrapLogger } from '../src/wrap-logger'
|
|
|
|
describe('logger', () => {
|
|
let output: string[]
|
|
beforeEach(() => {
|
|
output = []
|
|
|
|
logger.addStream({
|
|
level: 'trace',
|
|
stream: { write: (log: any) => output.push(log) } as any,
|
|
type: 'raw'
|
|
})
|
|
})
|
|
|
|
describe('child', () => {
|
|
test('sets attributes', () => {
|
|
const child = wrapLogger(logger).child({ id: '1234' })
|
|
child.debug('attributes will get added to this')
|
|
expect(output[0]).toHaveProperty('id', '1234')
|
|
})
|
|
|
|
test('allows setting the name', () => {
|
|
const child = wrapLogger(logger).child({ name: 'test' })
|
|
child.debug('hello')
|
|
expect(output[0]).toHaveProperty('name', 'test')
|
|
})
|
|
})
|
|
})
|