Winston logger cli方法不起作用

时间:2015-03-20 08:40:36

标签: logging command-line-interface winston

我正在我的记录器实例上尝试使用CLI mehtod来进行漂亮的打印,但它似乎没有用。

var logger = new winston.Logger({
transports: [

     new winston.transports.File({
        level: info
        filename: 'filename',
        json: true,
        name: 'all-log-file',
        colorize: true,
        prettyPrint: true
    })
 ]
});

logger.cli();

但这对我不起作用。预期的输出格式如下:

 info:   Found existing dependencies
 data:   {
 data:     colors: '0.x.x',
 data:     eyes: '0.1.x',
 data:     findit: '0.0.x',
 data:     npm: '1.0.x',
 data:     optimist: '0.2.x',
 data:     semver: '1.0.x',
 data:     winston: '0.2.x'
 data:   }
 info:   Analyzing dependencies...
 info:   Done analyzing raw dependencies
 info:   Retrieved packages from npm
 warn:   No additional dependencies found

我想要漂亮的彩色输出,有什么帮助?

1 个答案:

答案 0 :(得分:1)

您是否尝试过控制台传输?

var winston = require('winston');

var logger = new winston.Logger({
    transports: [
        new winston.transports.File({
            level: 'debug',
            filename: 'prettylog.txt',
            handleExceptions: true,
            json: false,
            colorize: true,
            timestamp: true,
            prettyPrint: true
        })
    ],
    exitOnError: false
});

现在,您必须使用标准Unix实用程序显示内容: cat prettylog.txt