Skip to content

Loading…

Make log level optional #22

Open
wants to merge 1 commit into from

1 participant

@buschtoens

This allows for

var Log = require("log")
  , log = new Log(someStream);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 1, 2013
  1. @buschtoens

    Make log level optional

    buschtoens committed
Showing with 9 additions and 4 deletions.
  1. +9 −4 lib/log.js
View
13 lib/log.js
@@ -15,15 +15,20 @@ var EventEmitter = require('events').EventEmitter;
* Initialize a `Loggeer` with the given log `level` defaulting
* to __DEBUG__ and `stream` defaulting to _stdout_.
*
- * @param {Number} level
+ * @param {Number} level optional
* @param {Object} stream
* @api public
*/
var Log = exports = module.exports = function Log(level, stream){
- if ('string' == typeof level) level = exports[level.toUpperCase()];
- this.level = isFinite(level) ? level : this.DEBUG;
- this.stream = stream || process.stdout;
+ if (level && (level.readable || level.writable)) {
+ this.level = exports.DEBUG;
+ this.stream = level;
+ } else {
+ if ('string' == typeof level) level = exports[level.toUpperCase()];
+ this.level = isFinite(level) ? level : exports.DEBUG;
+ this.stream = stream || process.stdout;
+ }
if (this.stream.readable) this.read();
};
Something went wrong with that request. Please try again.