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:
anor
2026-03-13 23:22:07 +10:00
co-authored by Claude Opus 4.6
parent 31de69f641
commit 4b9f3e0365
3 changed files with 49 additions and 1 deletions
+9
View File
@@ -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()