Adds a production-ready logging system with the following features: ## Core Features - Structured logging with rich context and metadata - Multiple log levels (DEBUG, INFO, WARNING, ERROR, CRITICAL) - File and console output with separate handlers - Automatic log rotation (prevents disk space issues) - Component-specific loggers for different parts of the system - Performance tracking with built-in metrics - API call tracking with cost and token monitoring ## New Components - tradingagents/utils/logging_config.py: Core logging module - TradingAgentsLogger: Main logger class - StructuredFormatter: Custom formatter with context - APICallLogger: Dedicated API call tracking - PerformanceLogger: Operation timing and metrics ## Log Files Created (in logs/ directory) - tradingagents.log: All application logs (10MB rotation, 5 backups) - errors.log: Errors only (5MB rotation, 3 backups) - api_calls.log: API call tracking - memory.log: Memory operations - agents.log: Agent execution - performance.log: Performance metrics ## Integration - Updated memory.py: Full logging integration with context - Logs initialization, embeddings, add/get operations - Tracks API calls and performance - Provides detailed error context - Updated trading_graph.py: Comprehensive graph logging - Logs initialization, propagation, reflection - Tracks component setup and execution - Performance metrics for all major operations - Updated default_config.py: Added logging configuration - log_level, log_dir, log_to_console, log_to_file ## Documentation - docs/LOGGING.md: Complete logging documentation (797 lines) - Quick start guide - Configuration examples - Best practices - API reference - Troubleshooting ## Benefits - Better debugging and troubleshooting - Production monitoring capabilities - API cost tracking - Performance analysis - Audit trail for decisions - Easier issue diagnosis Tested and working. See docs/LOGGING.md for complete usage guide. |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| conditional_logic.py | ||
| propagation.py | ||
| reflection.py | ||
| setup.py | ||
| signal_processing.py | ||
| trading_graph.py | ||