logging channels; training steps storage
This commit is contained in:
@@ -25,6 +25,7 @@ import threading
|
||||
import uuid
|
||||
import time
|
||||
import torch
|
||||
from utils.logging_config import get_channel_logger, LogChannel
|
||||
|
||||
# Import core components from main system
|
||||
try:
|
||||
@@ -98,6 +99,11 @@ logging.basicConfig(
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.info(f"Logging to: {log_file}")
|
||||
|
||||
# Create channel-specific loggers
|
||||
pivot_logger = get_channel_logger(__name__, LogChannel.PIVOTS)
|
||||
api_logger = get_channel_logger(__name__, LogChannel.API)
|
||||
webui_logger = get_channel_logger(__name__, LogChannel.WEBUI)
|
||||
|
||||
|
||||
class BacktestRunner:
|
||||
"""Runs backtest candle-by-candle with model predictions and tracks PnL"""
|
||||
@@ -941,7 +947,7 @@ class AnnotationDashboard:
|
||||
ts_str, idx = last_info['low']
|
||||
pivot_map[ts_str]['lows'][idx]['is_last'] = True
|
||||
|
||||
logger.info(f"Found {len(pivot_map)} pivot candles for {symbol} {timeframe} (from {len(df)} candles)")
|
||||
pivot_logger.info(f"Found {len(pivot_map)} pivot candles for {symbol} {timeframe} (from {len(df)} candles)")
|
||||
return pivot_map
|
||||
|
||||
except Exception as e:
|
||||
@@ -1067,7 +1073,7 @@ class AnnotationDashboard:
|
||||
'error': {'code': 'INVALID_REQUEST', 'message': 'Missing timeframe'}
|
||||
})
|
||||
|
||||
logger.info(f" Recalculating pivots for {symbol} {timeframe} using backend data")
|
||||
pivot_logger.info(f"Recalculating pivots for {symbol} {timeframe} using backend data")
|
||||
|
||||
if not self.data_loader:
|
||||
return jsonify({
|
||||
@@ -1094,7 +1100,7 @@ class AnnotationDashboard:
|
||||
# Recalculate pivot markers
|
||||
pivot_markers = self._get_pivot_markers_for_timeframe(symbol, timeframe, df)
|
||||
|
||||
logger.info(f" Recalculated {len(pivot_markers)} pivot candles")
|
||||
pivot_logger.info(f"Recalculated {len(pivot_markers)} pivot candles")
|
||||
|
||||
return jsonify({
|
||||
'success': True,
|
||||
@@ -1120,11 +1126,11 @@ class AnnotationDashboard:
|
||||
limit = data.get('limit', 2500) # Default 2500 candles for training
|
||||
direction = data.get('direction', 'latest') # 'latest', 'before', or 'after'
|
||||
|
||||
logger.info(f"Chart data request: {symbol} {timeframes} direction={direction} limit={limit}")
|
||||
webui_logger.info(f"Chart data request: {symbol} {timeframes} direction={direction} limit={limit}")
|
||||
if start_time_str:
|
||||
logger.info(f" start_time: {start_time_str}")
|
||||
webui_logger.info(f" start_time: {start_time_str}")
|
||||
if end_time_str:
|
||||
logger.info(f" end_time: {end_time_str}")
|
||||
webui_logger.info(f" end_time: {end_time_str}")
|
||||
|
||||
if not self.data_loader:
|
||||
return jsonify({
|
||||
@@ -1156,7 +1162,7 @@ class AnnotationDashboard:
|
||||
)
|
||||
|
||||
if df is not None and not df.empty:
|
||||
logger.info(f" {timeframe}: {len(df)} candles ({df.index[0]} to {df.index[-1]})")
|
||||
webui_logger.info(f" {timeframe}: {len(df)} candles ({df.index[0]} to {df.index[-1]})")
|
||||
|
||||
# Get pivot points for this timeframe (only if we have enough context)
|
||||
pivot_markers = {}
|
||||
@@ -2386,6 +2392,10 @@ def main():
|
||||
logger.info(f"Timestamp: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
|
||||
logger.info("=" * 80)
|
||||
|
||||
# Print logging channel configuration
|
||||
from utils.logging_config import print_channel_status
|
||||
print_channel_status()
|
||||
|
||||
dashboard = AnnotationDashboard()
|
||||
dashboard.run(debug=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user