66and compliance validation.
77"""
88
9+ import logging
910import os
10- from typing import List , Optional
11+ from typing import List , Literal , Optional
1112
12- from pydantic import BaseModel , Field , model_validator
13+ from pydantic import BaseModel , Field , field_validator , model_validator
1314from pydantic_settings import BaseSettings , SettingsConfigDict
1415from typing_extensions import Self
1516
@@ -25,6 +26,32 @@ def parse_comma_separated(value: str) -> List[str]:
2526 return []
2627
2728
29+ class _LoggingSettings (BaseSettings ):
30+ """Logging configuration settings."""
31+ model_config = SettingsConfigDict (
32+ env_prefix = "AZURE_" , env_file = DOTENV_PATH , extra = "ignore" , env_ignore_empty = True
33+ )
34+
35+ basic_logging_level : Literal ["DEBUG" , "INFO" , "WARNING" , "ERROR" ] = "INFO"
36+ package_logging_level : Literal ["DEBUG" , "INFO" , "WARNING" , "ERROR" ] = "WARNING"
37+ logging_packages : Optional [List [str ]] = []
38+
39+ @field_validator ("logging_packages" , mode = "before" )
40+ @classmethod
41+ def split_logging_packages (cls , packages ) -> Optional [List [str ]]:
42+ if isinstance (packages , str ) and len (packages .strip ()) > 0 :
43+ return [pkg .strip () for pkg in packages .split ("," ) if pkg .strip ()]
44+ return None
45+
46+ def get_basic_log_level (self ) -> int :
47+ """Convert string log level to logging constant."""
48+ return getattr (logging , self .basic_logging_level .upper ())
49+
50+ def get_package_log_level (self ) -> int :
51+ """Convert string package log level to logging constant."""
52+ return getattr (logging , self .package_logging_level .upper ())
53+
54+
2855class _UiSettings (BaseSettings ):
2956 """UI configuration settings."""
3057 model_config = SettingsConfigDict (
@@ -436,6 +463,7 @@ class _AppSettings(BaseModel):
436463 azure_openai : _AzureOpenAISettings = _AzureOpenAISettings ()
437464 ai_foundry : _AIFoundrySettings = _AIFoundrySettings ()
438465 brand_guidelines : _BrandGuidelinesSettings = _BrandGuidelinesSettings ()
466+ logging : _LoggingSettings = _LoggingSettings ()
439467 ui : Optional [_UiSettings ] = _UiSettings ()
440468
441469 # Constructed properties
0 commit comments