winstonjs/winston

Batch-Configuration of category loggers

Open

#970 opened on Jan 19, 2017

View on GitHub
 (5 comments) (2 reactions) (0 assignees)JavaScript (21,967 stars) (1,789 forks)batch import
Feature RequestGood First Issue

Description

The category feature of winston is quite cool. However, loggers like log4j base this on some thing like packages and support some kind of hierarchical configuration structure.

For example, you can configure a maximum log level for a package and all sub-packages inherit that setting and you can override that setting for a specific sub package.

In this issue I would like to have that kind of feature. It could perhaps be implemented in some kind of batch-configuration. For this, the category.get-method should support a regexp, that will return an interface to the configuration of all matching loggers.

Like this:

var winston = require('winston');

// Configure all categories.*-loggers to stop at warn

winston.loggers.get(/categories\..*/).configure({
    level: warn
});

// let info messages of categories.category1 go through

winston.loggers.get('categories.category1').configure({
  level: info
});

winston.loggers.get('categories.category1').info('This should get logged');
winston.loggers.get('categories.category2').info('This should not get logged');
winston.loggers.get('categories.category2').info('This should not get logged, too');

Contributor guide