Skip to content

Conversation

@hickey
Copy link

@hickey hickey commented Jun 5, 2024

This change recognizes the DEBUG_USE_STDOUT environmental variable to allow log messages to be directed to STDOUT when the NodeJS version is being used. Please refer to #964 for the use case to support this change.

I have added a test that I think will work for testing this functionality. Since my NodeJS knowledge is not that great I can not say for certain that it works as I expect it to. It is my hope that you will correct any problem with the test.

Closes #964

Signed-off-by: Gerard Hickey <hickey@kinetic-compute.com>
@hickey hickey force-pushed the choose_file_descriptor branch from 9481d46 to 27d567f Compare June 5, 2024 22:38
@hickey
Copy link
Author

hickey commented Jun 20, 2024

Anybody still working on this project?

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

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?

@endel
Copy link

endel commented Oct 30, 2025

I'm also looking forward to have this feature incorporated into debug.

When using debug with PM2, all "debug" logs end up displayed in the "errors" log file, which is not intuitive, considering those are just debug logs, and not necessary error logs.

@endel
Copy link

endel commented Oct 30, 2025

I just realized what I need is stated in the README, the solution is:

const mydebug = debug('myapp:debug')
mydebug.log = console.debug.bind(console);

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Allow choice between STDERR and STDOUT

2 participants