Skip to content

Disable stderr

Frank Kolarek requested to merge fkolarek/disable-stderr into main

Description

When rumba logs an ERROR, the underlying glog logging library also prints out the error text to stderr when log-severity is ERROR or FATAL. This is not desired when rumba is used as a compiler wrapper as it could create issues with upstream build tools that are looking at stderr output and could also cause confusion to our users. In the logging library, we set a few glog FLAGs that control logging to stderr to false if an output directory has been set. In order to change this behavior there is another flag, FLAGS_stderrthreshold, that can get set to FATAL in order to silence this behavior. Thankfully, the logging library has a function called disableStderr() that does just that.

Changes

As part of the logger initialization, call logging.disableStderr() if an output directory has been set.

Testing

Add a line anywhere in rumba.m.cpp that logs an error, ie

BUILDBOX_LOG_ERROR("Example error trace");

Build rumba and run a simple command and you'll see the error trace going to stderr:

$ mkdir build && cd build && cmake .. && make rumba
$ export RUMBA_LOG_DIRECTORY=.
$ ./rumba/rumba echo hello-world 
2022-02-25T07:32:40.464-0500 [4286:139778039511040] [rumba.m.cpp:164] [ERROR] Example error trace
hello-world

Next, clone this branch, rebuild and retest:

$ ./rumba/rumba echo hello-world 
hello-world

# confirm the log file still has the error trace
$ cat rumba.ERROR 
Log file created at: 2022/02/25 07:37:33
Running on machine: R912W2BG
Log line format: [IWEF]mmdd hh:mm:ss.uuuuuu threadid file:line] msg
2022-02-25T07:37:33.137-0500 [5528:140271630407680] [rumba.m.cpp:164] [ERROR] Example error trace
Edited by Frank Kolarek

Merge request reports