Skip to content

Commit

Permalink
[sos] Don't double log error level messages
Browse files Browse the repository at this point in the history
Only set the logging handler that prints ERROR level messages to console
if we're running in quiet mode, as otherwise we'll double log from the
normal console handler.

Closes: #1999
Resolves: #2033

Signed-off-by: Jake Hunsaker <[email protected]>
  • Loading branch information
TurboTurtle committed Apr 28, 2020
1 parent 1417827 commit ab44373
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sos/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ def _setup_logging(self):
else:
console.setLevel(logging.WARNING)
self.soslog.addHandler(console)
# log ERROR or higher logs to stderr instead
# still log ERROR level message to console, but only setup this handler
# when --quiet is used, as otherwise we'll double log
else:
console_err = logging.StreamHandler(sys.stderr)
console_err.setFormatter(logging.Formatter('%(message)s'))
console_err.setLevel(logging.ERROR)
Expand Down

0 comments on commit ab44373

Please sign in to comment.