From 689c98758d02e713b44b9756c74b158ed3974389 Mon Sep 17 00:00:00 2001 From: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> Date: Mon, 2 Dec 2024 14:04:13 +0200 Subject: [PATCH] fix: Logger to be local (#235) --- ai21/logger.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/ai21/logger.py b/ai21/logger.py index 61237d38..abc0820e 100644 --- a/ai21/logger.py +++ b/ai21/logger.py @@ -4,6 +4,7 @@ from ai21.ai21_env_config import AI21EnvConfig + _verbose = False logger = logging.getLogger("ai21") @@ -61,17 +62,15 @@ def get_verbose() -> bool: return _verbose -def _basic_config() -> None: - logging.basicConfig( - format="[%(asctime)s - %(name)s - %(levelname)s] %(message)s", - datefmt="%Y-%m-%d %H:%M:%S", - ) +def setup_logger() -> None: + handler = logging.StreamHandler() + handler.setFormatter( + CensorSecretsFormatter(fmt="[%(asctime)s - %(name)s - %(levelname)s] %(message)s", datefmt="%Y-%m-%d %H:%M:%S") + ) -def setup_logger() -> None: - _basic_config() - # Set the root handler with the censor formatter - logger.root.handlers[0].setFormatter(CensorSecretsFormatter()) + logger.addHandler(handler) + httpx_logger.addHandler(handler) if AI21EnvConfig.log_level.lower() == "debug": logger.setLevel(logging.DEBUG)