Manually handle/redirect output #69

Closed
walling opened this Issue Nov 5, 2013 · 9 comments

4 participants

@walling

It could be nice to be able to handle output manually instead of it going to stderr all the time. Example:

var debug = require('debug');

// Manually handle debug output. After this there are no output to stderr.
debug.handleOutput(function(message) {
  console.log(message.name, message.time, message.text);
});
@juliangruber

i found stderr output odd anyways, what's the reason that isn't sent to stdout?

@tj
Sloth member
tj commented Nov 5, 2013

yea might as well be stdout, it's just sort of an old unix hack to make sure you can separate the two easily but pretty unnecessary here +1

@walling

Just to clarify, I think my use case is more broad than just changing stderr to stdout. The idea is that you can overwrite where the output goes.

@tj
Sloth member
tj commented Nov 6, 2013

im not concerned about that part personally, debug isn't really meant to be enabled in production, but passing an optional stream would be fine

@walling

If you could parse any object that implements the write method (including writable streams like process.stdout and .stderr), I would love that.

@juliangruber

ideas:

DEBUG=stdout:express,connect
require('debug').to(process.stdout);
@walling

+1 for the the .to(...) pattern.

@TooTallNate

At this point you can override debug.log with a custom function. Does that work out for your use-case?

@TooTallNate

Definitely handled at this point by @timoxley in #108. Closing.

@TooTallNate TooTallNate closed this Jun 8, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment