In the following Ruby code, should logger default to `$stderr` or `$stdout`?

logger =

CSV do |csv| "Generating row..."
csv << ['1', '2', '3']

Please reply with your reasoning.

@ioquatix my first thought is that "info" isn't an error.

@phaedryx stderr is for diagnostics. Do you want to mix up info logger output in your CSV?

@ioquatix what if there weren't a default and you had to explicitly choose:

logger =
logger =


@phaedryx Right now there isn't any default. I wanted to propose to default to `stderr` because that's in line with POSIX standards, but there was a lot of push back, but I don't understand why. So, that's why I'm asking.

@ioquatix This is interesting because it isn't something I think much about. I've searched around and this is a point of contention several places; especially depending on how you define "diagnostic information".

Some links I found:

My current thinking is that "standard out" is for the standard (expected/typical) output? It is certainly more nuanced, though, than my initial reaction.

@phaedryx Is it normal output of the program (i.e. results)? Then it belongs on `stdout`. Otherwise it belongs on `stderr`. The original reason for `stderr` is because people used to print documents by piping the output into the printer device. Once the errors started coming out on the printer, apparently a few days later `stderr` was born :p

Sign in to participate in the conversation

A Mastodon instance for Rubyists & friends