Skip to content

Build and run agents you can see, understand and trust.

Improve logging setup by validating the input level (#715)

MirzaSamadAhmedBaig30cd271140b4
diff --git a/src/agentscope/_logging.py b/src/agentscope/_logging.py
index dd5f8c115..caf29a053 100644
--- a/src/agentscope/_logging.py
+++ b/src/agentscope/_logging.py
@@ -25,6 +25,11 @@ def setup_logger(
filepath (`str | None`, optional):
The filepath to save the logging output.
"""
+ if level not in ["INFO", "DEBUG", "WARNING", "ERROR", "CRITICAL"]:
+ raise ValueError(
+ f"Invalid logging level: {level}. Must be one of "
+ f"'INFO', 'DEBUG', 'WARNING', 'ERROR', 'CRITICAL'.",
+ )
logger.handlers.clear()
logger.setLevel(level)
handler = logging.StreamHandler()