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

chore: Remove logging hack #725

Merged
merged 1 commit into from
Sep 30, 2024
Merged
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
18 changes: 0 additions & 18 deletions binstar_client/utils/logging_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,31 +50,13 @@ def format(self, record: logging.LogRecord) -> str:
return super().format(record)


try:
from rich.logging import RichHandler
except (ImportError, ModuleNotFoundError):
RichHandler = None # type: ignore


def _purge_rich_handler_from_logging_root() -> None:
# Remove all handlers associated with the root logger object.
# We do this since anaconda-cli-base defines the RichHandler, which conflicts with anaconda-client's logging
# We can remove this once we clean up logging.
for handler in logging.root.handlers[:]:
# Only remove the root RichHandler, and only if rich is installed
# This should always happen, but just being super careful here.
if RichHandler is not None and isinstance(handler, RichHandler):
logging.root.removeHandler(handler)


def setup_logging(
logger: logging.Logger,
log_level: int = logging.INFO,
show_traceback: bool = False,
disable_ssl_warnings: bool = False
) -> None:
"""Configure logging for the application."""
_purge_rich_handler_from_logging_root()
logger.setLevel(logging.DEBUG)

os.makedirs(config.USER_LOGDIR, exist_ok=True)
Expand Down
Loading