Created
May 25, 2018 16:22
-
-
Save jion/a1df345a7920b3f4d6ac819e171297bd to your computer and use it in GitHub Desktop.
Allows to redirect all the messages on a specific logger to another specified logger
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
class RedirectLoggingHandler(logging.Handler): | |
def __init__(self, dest_logger): | |
logging.Handler.__init__(self) | |
self.dest_logger = dest_logger | |
def emit(self, record): | |
try: | |
record.name = self.dest_logger.name | |
self.dest_logger.handle(record) | |
except: | |
self.handleError(record) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment