Add option to log to STDOUT by hickey · Pull Request #965 · debug-js/debug · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions README.md
6 changes: 5 additions & 1 deletion src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,11 @@ function getDate() {
*/

function log(...args) {
return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + '\n');
if (exports.inspectOpts.useStdout) {
return process.stdout.write(util.formatWithOptions(exports.inspectOpts, ...args) + '\n');
} else {
return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + '\n');
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to cache which stream to use to avoid doing this if/else check at every log call?

}

/**
Expand Down
17 changes: 17 additions & 0 deletions test.node.js