mirror of
https://github.com/dnlbauer/cordra-mcp.git
synced 2026-09-11 14:15:31 +00:00
feat: add log level configuration and validation
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"""Configuration settings for the MCP Cordra server."""
|
||||
|
||||
from pydantic import Field
|
||||
from pydantic import Field, field_validator
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
||||
@@ -26,3 +26,21 @@ class CordraConfig(BaseSettings):
|
||||
default=True, description="Whether to verify SSL certificates"
|
||||
)
|
||||
timeout: int = Field(default=30, description="Request timeout in seconds")
|
||||
log_level: str = Field(
|
||||
default="INFO",
|
||||
description="Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)",
|
||||
validation_alias="LOGLEVEL",
|
||||
)
|
||||
|
||||
@field_validator("log_level", mode="before")
|
||||
@classmethod
|
||||
def validate_log_level(cls, v: str) -> str:
|
||||
"""Validate that log_level is a standard logging level."""
|
||||
level_str = str(v).upper().strip()
|
||||
valid_levels = {"DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"}
|
||||
|
||||
if level_str not in valid_levels:
|
||||
raise ValueError(
|
||||
f"Invalid log level '{v}'. Must be one of: {', '.join(valid_levels)}"
|
||||
)
|
||||
return level_str
|
||||
|
||||
Reference in New Issue
Block a user