Skip to content

Child loggers will not emit on parent after addStream() #479

@thanpolas

Description

@thanpolas

I'm using Bunyan for the purposes of an npm library. I have set it up so as to provide child-loggers for each module, and then expose the root logger.

When a stream is attached to the root logger using addStream() it will not receive any messages logged by the child loggers.

You can reproduce with the following snippet:

var rootLogger = bunyan.createLogger({
  name: 'root',
  level: 'info',
  // Mute logger
  streams: [],
});

var childLog = rootLogger.child({module: 'child-module'});

rootLogger.addStream({
  type: 'stream',
  stream: process.stdout,
}, 'debug');

childLog.debug('Hello there');
childLog.info('Hello there');
childLog.warn('Hello there');
childLog.error('Hello there');

console.log('should have logged');

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions