feat(logging): implement configurable belief state logging

- Add LoggingConfig model and logging field to GlobalSettings
- Implement belief_scope context manager for structured logging
- Add configure_logger for dynamic level and file rotation settings
- Add logging configuration UI to Settings page
- Update ConfigManager to apply logging settings on initialization and updates
This commit is contained in:
2025-12-27 05:39:33 +03:00
parent d197303b9f
commit 83e34e1799
10 changed files with 224 additions and 24 deletions

View File

@@ -16,7 +16,7 @@ import os
from pathlib import Path
from typing import Optional, List
from .config_models import AppConfig, Environment, GlobalSettings
from .logger import logger
from .logger import logger, configure_logger
# [/SECTION]
# [DEF:ConfigManager:Class]
@@ -38,10 +38,13 @@ class ConfigManager:
# 2. Logic implementation
self.config_path = Path(config_path)
self.config: AppConfig = self._load_config()
# Configure logger with loaded settings
configure_logger(self.config.settings.logging)
# 3. Runtime check of @POST
assert isinstance(self.config, AppConfig), "self.config must be an instance of AppConfig"
logger.info(f"[ConfigManager][Exit] Initialized")
# [/DEF:__init__]
@@ -120,7 +123,10 @@ class ConfigManager:
# 2. Logic implementation
self.config.settings = settings
self.save()
# Reconfigure logger with new settings
configure_logger(settings.logging)
logger.info(f"[update_global_settings][Exit] Settings updated")
# [/DEF:update_global_settings]