Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev(hansbug): add fallback for rick logging #9

Merged
merged 2 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion ditk/logging/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import os
from logging import LogRecord

import rich.errors

from .base import _LogLevelType
from .rich import _create_rich_handler
from .stream import _create_stream_handler
Expand Down Expand Up @@ -43,4 +45,11 @@
If ``DISABLE_RICH`` environment variable is set to non-empty, this method is equal to \
:meth:`logging.StreamHandler.emit`, otherwise equals to :meth:`rich.logging.RichHandler.emit`.
"""
return self._get_current_handler().emit(record)
try:
return self._get_current_handler().emit(record)
except rich.errors.ConsoleError:
if _use_rich():
stream_handler = _create_stream_handler(self.use_stdout, self.level)
return stream_handler.emit(record)

Check warning on line 53 in ditk/logging/terminal.py

View check run for this annotation

Codecov / codecov/patch

ditk/logging/terminal.py#L50-L53

Added lines #L50 - L53 were not covered by tests
else:
raise

Check warning on line 55 in ditk/logging/terminal.py

View check run for this annotation

Codecov / codecov/patch

ditk/logging/terminal.py#L55

Added line #L55 was not covered by tests
10 changes: 5 additions & 5 deletions requirements-doc.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Jinja2~=3.0.0
sphinx~=3.2.0
sphinx_rtd_theme~=0.4.3
enum_tools
Jinja2>=3.0.0
sphinx>=3.2.0
sphinx_rtd_theme>=0.4.3
enum_tools~=0.9.0
sphinx-toolbox
plantumlcli>=0.0.2
packaging
sphinx-multiversion~=0.2.4
sphinx-multiversion>=0.2.4
where~=1.0.2
easydict>=1.7,<2
Loading