0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-01-06 22:40:26 -05:00
verdaccio/packages/logger/logger-commons/test/createLogger.spec.ts
Juan Picado 631abe1ac1
refactor logger module (#3592)
* refactor logger module

* Update index.ts
2023-02-05 21:00:32 +01:00

21 lines
593 B
TypeScript

import pino from 'pino';
import { Writable } from 'stream';
import { createLogger } from '../src';
describe('logger test', () => {
describe('json format', () => {
test('should write json to a stream', () => {
const stream = new Writable({
write(chunk, encoding, callback) {
expect(JSON.parse(chunk.toString())).toEqual(
expect.objectContaining({ level: 30, msg: 'test' })
);
callback();
},
});
const logger = createLogger({ level: 'http' }, stream, 'json', pino);
logger.info('test');
});
});
});