Skip to content

Instantly share code, notes, and snippets.

@clintandrewhall
Created September 11, 2011 23:16
Show Gist options
  • Save clintandrewhall/1210263 to your computer and use it in GitHub Desktop.
Save clintandrewhall/1210263 to your computer and use it in GitHub Desktop.
Winston configuration...?
var config = {
"levels" : {
"detail": 0,
"trace": 1,
"debug": 2,
"enter": 3,
"info": 4,
"warning": 5,
"error": 6
},
"colors" : {
"detail": "grey",
"trace": "white",
"debug": "blue",
"enter": "inverse",
"info": "green",
"warning": "yellow",
"error": "red"
}
winston.cli();
winston.handleExceptions(new winston.transports.File({ filename: "logs/exceptions.log" }));
winston.addColors(config.colors);
winston.setLevels(config.levels);
winston.info("INFO");
winston.detail("DETAILS");
winston.info(winston.detail);
I GET:
info: INFO.
info: function (msg) {
var args = Array.prototype.slice.call(arguments),
callback = typeof args[args.length - 1] === 'function' ? args.pop() : null,
meta = args.length === 2 ? args.pop() : null;
require("sys").log(args);
return target.log(level, msg, meta, callback);
}
@indexzero
Copy link

You've found a bug :-D. Here's what is happening.

  1. You setup your own levels
  2. The default logging level is set to info. This means anything below info is silenced
  3. For a normal instance of winston.Logger you can just set the level property
  4. The level property is not exposed properly on the default logger (i.e. the winston object).

Associated source: https://github.com/indexzero/winston/blob/master/lib/winston.js#L31-61
Issue filed: https://github.com/indexzero/winston/issues/38

@indexzero
Copy link

btw, always happy to help on this sort of question, but Twitter is not my preferred method of communication for bugs and issues. In the future, just open a Github issue. I try to be quick to respond to those as well.

@clintandrewhall
Copy link
Author

clintandrewhall commented Sep 11, 2011 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment