Skip to content

Commit

Permalink
Temporarily change stderr log level to silence log.init if --quiet
Browse files Browse the repository at this point in the history
Otherwise, if disk logging is configured, it prints 'logging to /path/to/something' even when in quiet mode (https://github.com/twitter/commons/blob/master/src/python/twitter/common/log/initialize.py#L285)

Testing Done:
pantsbuild#743

https://travis-ci.org/pantsbuild/pants/builds/39412239

Reviewed at https://rbcommons.com/s/twitter/r/1243/
  • Loading branch information
dt authored and jsirois committed Oct 29, 2014
1 parent c7ba927 commit 88bc3f6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/python/pants/commands/goal_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,19 @@ def run(self, lock):
if logdir:
safe_mkdir(logdir)
LogOptions.set_log_dir(logdir)

prev_log_level = None
# If quiet, temporarily change stderr log level to kill init's output.
if self.old_options.quiet:
prev_log_level = LogOptions.loglevel_name(LogOptions.stderr_log_level())
# loglevel_name can fail, so only change level if we were able to get the current one.
if prev_log_level is not None:
LogOptions.set_stderr_log_level(LogOptions._LOG_LEVEL_NONE_KEY)

log.init('goals')

if prev_log_level is not None:
LogOptions.set_stderr_log_level(prev_log_level)
else:
log.init()

Expand Down

0 comments on commit 88bc3f6

Please sign in to comment.