Skip to content

Commit

Permalink
Allow to customize log levels (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
kongzii authored May 17, 2024
1 parent 9edc6e9 commit 1e497ff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions prediction_market_agent_tooling/loggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down Expand Up @@ -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.
Expand All @@ -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,
)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 1e497ff

Please sign in to comment.