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.