Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
malmans2 committed Mar 20, 2024
1 parent 41eb841 commit b6c81db
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions cads_api_client/legacy_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,22 @@

class LoggingContext:
def __init__(self, logger: logging.Logger, quiet: bool, debug: bool) -> None:
self.logger = logger
self.old_level = self.logger.level

self.old_level = logger.level
if quiet:
self.logger.setLevel(logging.WARNING)
logger.setLevel(logging.WARNING)
else:
self.logger.setLevel(logging.DEBUG if debug else logging.INFO)
logger.setLevel(logging.DEBUG if debug else logging.INFO)

self.new_handlers = []
if not self.logger.handlers:
if not logger.handlers:
formatter = logging.Formatter("%(asctime)s %(levelname)s %(message)s")
handler = logging.StreamHandler()
handler.setFormatter(formatter)
self.logger.addHandler(handler)
logger.addHandler(handler)
self.new_handlers.append(handler)

self.logger = logger

def __enter__(self) -> logging.Logger:
return self.logger

Expand Down

0 comments on commit b6c81db

Please sign in to comment.