winstonjs/winston

Custom log levels can be silent unless level is also specified

Open

#1,491 opened on 2018年10月3日

GitHub で見る
 (6 comments) (0 reactions) (0 assignees)JavaScript (21,967 stars) (1,789 forks)batch import
BugGood First IssueHelp Wanted

説明

It is easy to write the following code and not realize that one has made a mistake:

const logger = winston.createLogger({
  levels: { eeny: 0, meeny: 1, miney: 2, moe: 3},
  transports: [
    new winston.transports.Console(),
  ]
});

logger.meeny('catch a tiger by the toe'); // never hollers

This could be addressed by the following check in the Logger constructor:

    if (!Object.keys(this.levels).includes(this.level)) {
      throw new Error(`Logger level ${this.level} is not in the levels: ${this.levels}`);
    }

I can open a PR if people agree it is worth fixing.

コントリビューターガイド