Skip to content

Commit

Permalink
fix: Logger to be local (#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
Josephasafg authored Dec 2, 2024
1 parent 276653e commit 689c987
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions ai21/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from ai21.ai21_env_config import AI21EnvConfig


_verbose = False

logger = logging.getLogger("ai21")
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 689c987

Please sign in to comment.