feat: логирование всех действий — file + journald
- cli.py: RotatingFileHandler (data/scalp-bot.log, 5MB, 3 backup) - executor: log.info/warning/error на каждое действие (cycle, entry, exit, slippage, equity, candidates, holiday/weekend skip) - state: логирование open/close_position, equity changes, peak equity - Все log.* дублируют logs.append — и в journald, и в CLI output Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,17 +5,26 @@ from __future__ import annotations
|
||||
import logging
|
||||
import signal
|
||||
import sys
|
||||
from logging.handlers import RotatingFileHandler
|
||||
from pathlib import Path
|
||||
|
||||
import click
|
||||
|
||||
from config import load_config
|
||||
from state import get_db, get_equity, get_open_positions, get_trade_history, init_db
|
||||
|
||||
LOG_DIR = Path(__file__).parent / "data"
|
||||
LOG_DIR.mkdir(exist_ok=True)
|
||||
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format="%(asctime)s %(levelname)s %(name)s: %(message)s",
|
||||
datefmt="%H:%M:%S",
|
||||
)
|
||||
# File handler: rotate at 5 MB, keep 3 backups
|
||||
_fh = RotatingFileHandler(LOG_DIR / "scalp-bot.log", maxBytes=5_000_000, backupCount=3)
|
||||
_fh.setFormatter(logging.Formatter("%(asctime)s %(levelname)s %(name)s: %(message)s"))
|
||||
logging.getLogger().addHandler(_fh)
|
||||
|
||||
|
||||
@click.group()
|
||||
|
||||
Reference in New Issue
Block a user