winstonjs/winston

Batch-Configuration of category loggers

Open

#970 创建于 2017年1月19日

在 GitHub 查看
 (5 评论) (2 反应) (0 负责人)JavaScript (21,967 star) (1,789 fork)batch import
Feature RequestGood First Issue

描述

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');

贡献者指南