From 1e497fff9f2b53e4e3e1beb5dda08b4d49da881b Mon Sep 17 00:00:00 2001 From: Peter Jung Date: Fri, 17 May 2024 10:43:43 +0200 Subject: [PATCH] Allow to customize log levels (#254) --- prediction_market_agent_tooling/loggers.py | 13 +++++++++++-- pyproject.toml | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/prediction_market_agent_tooling/loggers.py b/prediction_market_agent_tooling/loggers.py index 487c6e06..8bf42cf8 100644 --- a/prediction_market_agent_tooling/loggers.py +++ b/prediction_market_agent_tooling/loggers.py @@ -14,12 +14,21 @@ class LogFormat(str, Enum): GCP = "gcp" +class LogLevel(str, Enum): + CRITICAL = "CRITICAL" + ERROR = "ERROR" + WARNING = "WARNING" + INFO = "INFO" + DEBUG = "DEBUG" + + class LogConfig(BaseSettings): model_config = SettingsConfigDict( env_file=".env", env_file_encoding="utf-8", extra="ignore" ) LOG_FORMAT: LogFormat = LogFormat.DEFAULT + LOG_LEVEL: LogLevel = LogLevel.DEBUG GCP_LOG_LOGURU_FORMAT = ( @@ -49,7 +58,7 @@ def patch_logger() -> None: # Change built-in logging. if format_logging is not None: logging.basicConfig( - level=logging.DEBUG, format=format_logging, datefmt=datefmt_logging + level=config.LOG_LEVEL.value, format=format_logging, datefmt=datefmt_logging ) # Change loguru. @@ -58,7 +67,7 @@ def patch_logger() -> None: logger.add( sys.stdout, format=format_loguru, - level="DEBUG", # Can be the lowest level, higher ones will use by default this one. + level=config.LOG_LEVEL.value, colorize=True, ) diff --git a/pyproject.toml b/pyproject.toml index 0e052d53..fa74a217 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "prediction-market-agent-tooling" -version = "0.30.0" +version = "0.31.0" description = "Tools to benchmark, deploy and monitor prediction market agents." authors = ["Gnosis"] readme = "README.md"