diff --git a/rich/logging.py b/rich/logging.py index b2624cd54..299ed6b58 100644 --- a/rich/logging.py +++ b/rich/logging.py @@ -129,7 +129,7 @@ def get_level_text(self, record: LogRecord) -> Text: ) return level_text - def emit(self, record: LogRecord) -> None: + def _emit(self, record: LogRecord) -> None: """Invoked by logging.""" message = self.format(record) traceback = None @@ -179,6 +179,12 @@ def emit(self, record: LogRecord) -> None: except Exception: self.handleError(record) + def emit(self, record: LogRecord) -> None: + try: + return self._emit(record) + except Exception: + self.handleError(record) + def render_message(self, record: LogRecord, message: str) -> "ConsoleRenderable": """Render message text in to Text.