@@ -34,6 +34,31 @@ class _UiSettings(BaseSettings):
3434 show_share_button : bool = False
3535
3636
37+ class _LoggingSettings (BaseSettings ):
38+ model_config = SettingsConfigDict (
39+ env_prefix = "AZURE_" , env_file = DOTENV_PATH , extra = "ignore" , env_ignore_empty = True
40+ )
41+
42+ basic_logging_level : Literal ["DEBUG" , "INFO" , "WARNING" , "ERROR" ] = "INFO"
43+ package_logging_level : Literal ["DEBUG" , "INFO" , "WARNING" , "ERROR" ] = "WARNING"
44+ logging_packages : Optional [List [str ]] = []
45+
46+ @field_validator ("logging_packages" , mode = "before" )
47+ @classmethod
48+ def split_logging_packages (cls , packages ) -> Optional [List [str ]]:
49+ if isinstance (packages , str ) and len (packages .strip ()) > 0 :
50+ return [pkg .strip () for pkg in packages .split ("," ) if pkg .strip ()]
51+ return None
52+
53+ def get_basic_log_level (self ) -> int :
54+ """Convert string log level to logging constant"""
55+ return getattr (logging , self .basic_logging_level .upper ())
56+
57+ def get_package_log_level (self ) -> int :
58+ """Convert string package log level to logging constant"""
59+ return getattr (logging , self .package_logging_level .upper ())
60+
61+
3762class _ChatHistorySettings (BaseSettings ):
3863 model_config = SettingsConfigDict (
3964 env_prefix = "AZURE_COSMOSDB_" ,
@@ -367,6 +392,7 @@ class _AppSettings(BaseModel):
367392 azure_ai : _AzureAISettings = _AzureAISettings ()
368393 search : _SearchCommonSettings = _SearchCommonSettings ()
369394 ui : Optional [_UiSettings ] = _UiSettings ()
395+ logging : _LoggingSettings = _LoggingSettings ()
370396
371397 # Constructed properties
372398 chat_history : Optional [_ChatHistorySettings ] = None
0 commit comments