简体   繁体   English

如何在Winston Loggin系统中启用颜色?

[英]How to enable colors in winston loggin system?

What is the simplest way to enable default colors logs messages in winston? 在Winston中启用默认颜色日志消息的最简单方法是什么?

For example, if I use winston as follows: 例如,如果我按如下方式使用winston:

let winston = require('winston')

winston.info('Info message')
winston.error('Error message')

I expect that the colors of info and error message will be respectively yellow and red? 我希望infoerror消息的颜色分别为黄色和红色?

Even though info won't be yellow I would suggest you use winston-color : 即使info不会是黄色的,我还是建议您使用winston-color

const logger = require( 'winston-color' );
logger.info( 'Info message' ); // Will print info in green
logger.error( 'Error message' ); // Will print error in red

You can use: 您可以使用:

let winston = require('winston')
winston.cli();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM