Skip to content

Conversation

@gourlaysama
Copy link
Contributor

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.


The second commit uses that to fix a 6-year-old issue, SI-1264.

@gourlaysama
Copy link
Contributor Author

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.
@som-snytt
Copy link
Contributor

Usually the Scala folks try to emulate Java in conventional behaviors.

apm@mara:~/tmp$ javac -help jex/Example.java 2> /dev/null
apm@mara:~/tmp$ 

@gourlaysama
Copy link
Contributor Author

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 (stderr, stderr) the default, so we still keep the ability to send things to two different places but that a non-standard choice (only used when connecting to fsc).

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?

@gourlaysama
Copy link
Contributor Author

Hmm, I am closing this. I'll fix the fsc thing first and go back to reporters later.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants