Open J-Moravec opened 2 years ago
Just to clarify: BEAST classes should not use stdout and stderr directly, but should produce output through the Log
class, which has 5 PrintStreams: error, info, warning, debug, trace. By default, debug and trace are suppressed, info is output through stdout and error and warning through stderr.
What gets shown is determined through the Log.level
setting. For example, running BEAST with -loglevel info
should suppress all these warning messages (as well as debug and trace messages). Perhaps running beast -loglevel info testHKY.xml > stdin.txt 2> stderr.txt
is already what you are looking for what running BEAST is concerned?
Maybe a "silent" option for unit tests could be implemented by setting the log-level using Log.setLevel()
for all unit tests.
Thanks Remco, I am looking at the -loglevel
variable and testing various outputs.
Running beast -loglevel <level> testHKY.xml > stdin.txt
None of these log levels fully eliminate the stderr.
On top of it, sometimes what is an error ends up in stdout.
My conclusion is that some parts of BEAST
do not correctly label/assign messages into the correct (internal) stream. Such as the loading package message:
Loading package is a normal function of BEAST
it should IMHO not be put into warning stream unless something unexpected has happened, such as when a file couldn't get opened:
Again, the idea is not to suppress the output (which -loglevel
does), but to make sure it goes into the correct stream. After all, the whole reason why I am raising the issue is that warnings and errors are important and should not be confused by everything is running correctly
messages. What is even worse, some error messages are not even in the error stream, but stdout.
I will check the Log.setLevel()
for unit-tests.
You are right that the philosophy behind the use of the Log
class is not consistently implemented, and indeed it would be good to review the code for this. If you would be willing to have a go at this that will be really great!
Stdout and stderr should certainly not be used, since these messages may not end up with the user (I think BEAST running in a console or BEAUti's message menu may capture only some of the messages).
PS You are aware of the v2.7 code quake (commits 521ca914a7d1a2103180729a989766b27dc42cca and later + #1030), which refactors much of the code. There is still a v2.6 branch, but updates of the master branch are preferred.
Stderr should be empty for a run, where no error was encountered. Currently, some extra information is printed to stderr. These are not warnings, these are not errors, just messages informing the user. This pollution of stderr makes it harder to programmatically reason about stderr.
For example, running
BEAST
ontestHKY.xml
and redirecting both stdin and stderr to different files:the content of
stderr.txt
is:This is not
stderr
and fits squarely into thestdin
produced byBEAST
, given that the output is for human consumption and not something that would be further piped:I have also noticed that, when running some unit-tests, an extra output is printed to
stdin
, specifically the information about alignment. Ideally, unit-tests should be completely silent if they are working properly, so if there is an agreement, I will try to hunt them down and try to fix them, by adding asilent
option.