I'm making a script that handles a predefined set of data, outputting to a file. I want to pop up a warning when one datum (which is always "Regular" in every set that I've had access to) is different stating that this value is unhandled (since I don't know how it affects the data). Should I output this warning to stderr or stdout?
Warning logs are not errors. None of these should go to stderr by default. Only error logs should go to stderr.
Your screen is the standard output, sometimes denoted as stdout . By default, commands take input from the standard input and send the results to standard output. Standard error, sometimes denoted as stderr, is where error messages go. By default, this is your screen.
STDERR_FILENO is an output file descriptor. You can't read from it.
If I saved the output of this script (i.e. stdout only) so that I could process it later, would that warning interfere with how the output is parsed? Moreover, if output is piped to another process, the warning should show up on the terminal, so the user sees it immediately.
For those reasons, in general, you output warnings to stderr.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With