Skip to content

Commit

Permalink
test: added more tests to verify the output streams in default logger
Browse files Browse the repository at this point in the history
abhilash-sivan committed Jan 3, 2025
1 parent d51bf8a commit 12f5eb0
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/collector/test/logger_test.js
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ const bunyan = require('bunyan');
const pino = require('pino');

const log = require('../src/logger');
const { expectAtLeastOneMatching } = require('../../core/test/test_util');

describe('logger', () => {
beforeEach(resetEnv);
@@ -152,4 +153,21 @@ describe('logger', () => {
const logger2 = bunyan.createLogger({ name: 'new-logger' });
log.init({ logger: logger2 });
});

it('should verify the output streams', () => {
log.init({});
const logger = log.getLogger('myLogger');
expect(logger).to.be.an.instanceOf(bunyan);

expect(logger.streams).to.be.an('array');
// 1 x default stream that prints to stdout
// 1 x custom stream that goes to agent stream
expect(logger.streams).to.have.lengthOf(2);

expectAtLeastOneMatching(
logger.streams,
stream => expect(stream.type).to.equal('raw'),
stream => expect(stream.level).to.equal('info')
);
});
});

0 comments on commit 12f5eb0

Please sign in to comment.