Skip to Content [alt-c]


In reply to Comment by Anonymous

Andrew Ayer on 2020-01-07 at 00:57:

stdout is meant for the output of a program. It's where curl writes the file that it downloads. It's where a CGI webapp writes the response headers and body. It's how a server started by inetd communicates with the client. If a library logs messages to stdout, those messages will disrupt a program's output and could cause serious problems to the whoever is processing it.

Using stderr instead of stdout avoids the worst problems, but it's still usually not what you want a library to do. If the library needs to report an error, which was the case with, it should return it to the caller (or throw an exception, depending on the language's conventions). If a library has a legitimate need to log, then it should log to a logger provided by the user of the library, so they have control over where the messages go.


Post a Reply

Your comment will be public. To contact me privately, email me. Please keep your comment polite, on-topic, and comprehensible. Your comment may be held for moderation before being published.

(Optional; will be published)

(Optional; will not be published)

(Optional; will be published)

  • Blank lines separate paragraphs.
  • Lines starting with > are indented as block quotes.
  • Lines starting with two spaces are reproduced verbatim (good for code).
  • Text surrounded by *asterisks* is italicized.
  • Text surrounded by `back ticks` is monospaced.
  • URLs are turned into links.
  • Use the Preview button to check your formatting.