Files
DeepTutor/deeptutor/logging/config.py
Bingxi Zhao (Frank) 100576da69 release: v1.1.2 — schema-driven channels, secret masking, RAG simplification, KB-consistency hardening
* TutorBot Channels tab is now schema-driven across every built-in & plugin channel
  (GET /api/v1/tutorbot/channels/schema), with per-field secret reveal toggles.
* Channel secrets are masked end-to-end; raw values only surface via the explicit
  ?include_secrets=true edit-form route. PATCH validates ChannelsConfig at the API
  boundary and returns 422 on bad payloads. reload_channels is serialised by an
  asyncio.Lock and records last_reload_error for the UI.
* Collapsed services/rag/ to a single LlamaIndex pipeline: removed ~2.6k lines of
  unused components/* + pipeline.py + types.py + utils/ + parsers/. rag_provider
  is now a stub; legacy values silently coerce to llamaindex.
* Centralised file routing into services/rag/file_routing.py (FileTypeRouter /
  DocumentType / FileClassification); dropped per-provider extension helpers.
* Defensive RAG/KB consistency: deep_solve / deep_research strip rag/kb when no
  KB is attached; SolveToolRuntime + ResearchPipeline + DecomposeAgent
  short-circuit instead of falling back to non-existent default KBs (DE-all,
  ai_textbook).
* Externalised AgenticChatPipeline prompts into agentic_chat.yaml (zh + en).
* Added Thai README (#337).
* New test modules: file_routing, knowledge_base_config, channel_schema,
  channel_secrets, rag_consistency, research_pipeline_rag.

Full notes: assets/releases/ver1-1-2.md

Made-with: Cursor
2026-04-18 11:33:53 +08:00

79 lines
2.1 KiB
Python

"""
Logging Configuration
=====================
Unified logging configuration for the entire DeepTutor system.
A single `level` parameter controls all logging (including RAG modules).
"""
from dataclasses import dataclass
from pathlib import Path
from typing import Optional
@dataclass
class LoggingConfig:
"""Configuration for the logging system."""
# Global log level (controls entire system including RAG modules)
level: str = "DEBUG"
# Output settings
console_output: bool = True
file_output: bool = True
# Log directory (relative to project root or absolute)
log_dir: Optional[str] = None
# File rotation settings
max_bytes: int = 10 * 1024 * 1024 # 10MB
backup_count: int = 5
def get_default_log_dir() -> Path:
"""Get the default log directory."""
from deeptutor.services.path_service import get_path_service
path_service = get_path_service()
return path_service.get_logs_dir()
def get_global_log_level() -> str:
"""
Get the global log level from config/main.yaml -> logging.level
Default: DEBUG
"""
try:
from deeptutor.services.config import PROJECT_ROOT, load_config_with_main
config = load_config_with_main("main.yaml", PROJECT_ROOT)
logging_config = config.get("logging", {})
return logging_config.get("level", "DEBUG").upper()
except Exception:
return "DEBUG"
def load_logging_config() -> LoggingConfig:
"""
Load logging configuration from config files.
Returns:
LoggingConfig instance with loaded or default values.
"""
try:
from deeptutor.services.config import PROJECT_ROOT, get_path_from_config, load_config_with_main
config = load_config_with_main("main.yaml", PROJECT_ROOT)
logging_config = config.get("logging", {})
level = get_global_log_level()
return LoggingConfig(
level=level,
console_output=logging_config.get("console_output", True),
file_output=logging_config.get("save_to_file", True),
log_dir=get_path_from_config(config, "user_log_dir"),
)
except Exception:
return LoggingConfig()