From 656505da986573658db984c9886da135540e02c1 Mon Sep 17 00:00:00 2001 From: Philipp Temminghoff Date: Sat, 30 Nov 2024 10:13:49 +0100 Subject: [PATCH] feat: allow setting log level in global conf --- src/llmling/config/models.py | 4 ++++ src/llmling/server/factory.py | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/llmling/config/models.py b/src/llmling/config/models.py index 6fd8960..6bb3fd1 100644 --- a/src/llmling/config/models.py +++ b/src/llmling/config/models.py @@ -17,6 +17,7 @@ ResourceType = Literal["path", "text", "cli", "source", "callable", "image"] +LogLevel = Literal["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] class GlobalSettings(BaseModel): @@ -40,6 +41,9 @@ class GlobalSettings(BaseModel): prefer_uv: bool = False """Explicitely use uv for package installation / management """ + log_level: LogLevel = "INFO" + """Log level to use for the server""" + model_config = ConfigDict(frozen=True) diff --git a/src/llmling/server/factory.py b/src/llmling/server/factory.py index 9140496..996b903 100644 --- a/src/llmling/server/factory.py +++ b/src/llmling/server/factory.py @@ -7,7 +7,7 @@ from llmling import config_resources from llmling.config.manager import ConfigManager from llmling.config.runtime import RuntimeConfig -from llmling.core.log import get_logger +from llmling.core.log import get_logger, setup_logging from llmling.server.server import LLMLingServer @@ -38,6 +38,7 @@ def create_server( # Load and validate config path = config_path or config_resources.TEST_CONFIG manager = ConfigManager.load(path) + setup_logging(level=manager.config.global_settings.log_level) # Log any validation warnings if warnings := manager.validate():