plg4-dev-server / backend /docs /logging_guide.md
Jesse Johnson
New commit for backend deployment: 2025-09-25_13-24-03
c59d808

Logging Example and Configuration

Logging Features Implemented

1. Centralized Logging Configuration

  • File: config/logging_config.py
  • Features:
    • Rotating file logs (10MB max, 5 backups)
    • Console and file output
    • Structured format with timestamps, levels, and source location
    • Environment-based configuration

2. Service-Level Logging

  • Vector Store Service: Logs initialization, document loading, provider setup
  • LLM Service: Logs model setup, question processing, memory operations
  • API Endpoints: Logs requests, responses, and errors

3. Log Levels Used

  • INFO: Normal operations, successful completions
  • DEBUG: Detailed operation steps, memory operations
  • WARNING: Non-critical issues, fallbacks
  • ERROR: Failures, exceptions (with stack traces)

4. Emoji-Coded Log Messages

  • πŸš€ Startup/Initialization
  • βœ… Success operations
  • ❌ Error conditions
  • ⚠️ Warning conditions
  • πŸ”§ Configuration/Setup
  • πŸ’¬ Chat operations
  • 🧠 Memory operations
  • πŸ“Š Database operations
  • πŸ” Search/Retrieval
  • πŸ’Ύ Storage operations

Usage Examples

from config.logging_config import get_logger

# Get a logger for your module
logger = get_logger("my_module")

# Log at different levels
logger.info("βœ… Operation completed successfully")
logger.warning("⚠️ Using fallback configuration")
logger.error("❌ Operation failed", exc_info=True)  # Includes stack trace

Log File Location

  • Path: ./logs/recipe_bot.log
  • Rotation: Automatic when file exceeds 10MB
  • Backups: Keeps 5 backup files

Console Output

All logs are also displayed in the console with colored formatting for easy debugging during development.