make ConsoleReporter handle both stdout and stderr#3930
make ConsoleReporter handle both stdout and stderr#3930gourlaysama wants to merge 2 commits intoscala:2.11.xfrom
Conversation
|
This replaces my previous attempt at fixing SI-1264: #3919. partest doesn't keep stdout/stderr separate, so if anyone has any idea of how to test that, I would gladly add tests. |
scala and scalac always had a problem with deciding where to send messages in the console and just sent everything to stderr, so it is time to improve that: ConsoleReporter now takes two PrintWriter, one for errors/warnings and one for normal messages. The short constructor sets them to stderr and stdout, respectively. This finally makes scala(c) ouput like any normal program. For example: $ scalac -help > /dev/null # will now print nothing $ scala -nc -e "val" > /dev/null # will print an error message $ scala -nc -e "println(1)" > /dev/null # but this won't People calling the old constructor (with a single writer) get no change in behavior: everything goes to the writer.
This properly splits the output of fsc (from `scala -e`, scala worksheet, etc.) between stderr (for warnings and errors) and stdout (for the rest). With this change, fsc behaves the same as `scalac`. This makes the fsc server prefix messages with the destination ([err]/[out]), and the client socket strip them and send the rest to the client stderr/stdout.
|
Usually the Scala folks try to emulate Java in conventional behaviors. |
|
Hmm, true, java does that. On the other hand, a lot of programs out there follow the GNU CLI convention (which goes the other way). The standard on Windows is also stdout... I guess this is controversial. I should just make But that's still a global choice, we lose the ability to report normal "non-diagnostic" stuff. Maybe there should be 4 levels and not 3 then: 3 for diagnostics (ERROR, WARN, DEBUG or similar), and a normal INFO level that does just that, inform the user about something? |
|
Hmm, I am closing this. I'll fix the fsc thing first and go back to reporters later. |
scalaandscalacalways had a problem with deciding where to sendmessages in the console and just sent everything to stderr, so it is
time to improve that:
ConsoleReporternow takes twoPrintWriter, one for errors/warnings andone for normal messages. The short constructor sets them to stderr and
stdout, respectively.
This finally makes scala(c) ouput like any normal program. For example:
People calling the old constructor (with a single writer) get no change
in behavior: everything goes to the writer.
The second commit uses that to fix a 6-year-old issue, SI-1264.