Merge pull request #285 from dw/issue272

issue #272: add a blacklist for noisy target loggers
pull/292/head
dw 7 years ago committed by GitHub
commit 58335ab48e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -45,9 +45,20 @@ class Handler(logging.Handler):
self.display = display self.display = display
self.normal_method = normal_method self.normal_method = normal_method
#: Set of target loggers that produce warnings and errors that spam the
#: console needlessly. Their log level is forced to INFO. A better strategy
#: may simply be to bury all target logs in DEBUG output, but not by
#: overriding their log level as done here.
NOISY_LOGGERS = frozenset([
'dnf', # issue #272; warns when a package is already installed.
])
def emit(self, record): def emit(self, record):
if getattr(record, 'mitogen_name', '') == 'stderr': mitogen_name = getattr(record, 'mitogen_name', '')
if mitogen_name == 'stderr':
record.levelno = logging.ERROR record.levelno = logging.ERROR
if mitogen_name in self.NOISY_LOGGERS and record.levelno >= logging.WARNING:
record.levelno = logging.DEBUG
s = '[pid %d] %s' % (os.getpid(), self.format(record)) s = '[pid %d] %s' % (os.getpid(), self.format(record))
if record.levelno >= logging.ERROR: if record.levelno >= logging.ERROR:

Loading…
Cancel
Save