I'm trying to get Winston to pretty print to the console, so I stuck this in a file and ran it with node:
var winston = require('winston');
winston.cli();
winston.data({
a: "test",
of: "many",
properties: {
like: "this"
}
});
winston.data('data', {
a: "test",
of: "many",
properties: {
like: "this"
}
});
The terminal spit back the following (not exactly pretty) messages:
data: a=test, of=many, like=this
data: data a=test, of=many, like=this
I'm following the instructions on the Winston Readme ("Using winston in a CLI tool"). Am I misreading something? Missing a setting somewhere?
I figured out the answer (the documentation is incorrect). If you use the constructor, and manually add transports, you can set options, both for winston, and for individual transports. Certain options need to be added to winston directly, while others need to be added to the transport.
E.g.:
var winston = require('winston');
var logger = new (winston.Logger)({
levels: {
trace: 0,
input: 1,
verbose: 2,
prompt: 3,
debug: 4,
info: 5,
data: 6,
help: 7,
warn: 8,
error: 9
},
colors: {
trace: 'magenta',
input: 'grey',
verbose: 'cyan',
prompt: 'grey',
debug: 'blue',
info: 'green',
data: 'grey',
help: 'cyan',
warn: 'yellow',
error: 'red'
}
});
logger.add(winston.transports.Console, {
level: 'trace',
prettyPrint: true,
colorize: true,
silent: false,
timestamp: false
});
logger.add(winston.transports.File, {
prettyPrint: false,
level: 'info',
silent: false,
colorize: true,
timestamp: true,
filename: './nKindler.log',
maxsize: 40000,
maxFiles: 10,
json: false
});