feat: 增加运行日志(不记录敏感信息) - 启动摘要:端口/间隔/重试/超时/并发/Telegram 状态/内置平台/账号数/数据库路径 - 检查结果:成功余额、认证失败禁用、失败原因 - 提醒状态机:触发提醒/余额恢复 - API 操作:登录、平台/账号增删改、设置修改、密码修改 - Telegram 发送成功、请求耗时(DEBUG) - 全部日志不含 apikey/token/密码

This commit is contained in:
2026-08-05 10:21:05 +08:00
parent c4f5c64804
commit 96e937e523
6 changed files with 35 additions and 2 deletions
+15 -1
View File
@@ -6,19 +6,33 @@ import logging
import uvicorn
from app import db
from app.api import create_app
from app.config import load_config
from app.providers import list_providers
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
)
logger = logging.getLogger("monitor.main")
def main() -> None:
cfg = load_config()
app = create_app(cfg)
print(f"AI Balance Monitor 已启动: http://127.0.0.1:{cfg.port}")
tg = "已配置" if cfg.telegram_bot_token and cfg.telegram_chat_id else "未配置"
with db.get_conn() as conn:
total = conn.execute("SELECT COUNT(*) FROM accounts").fetchone()[0]
enabled = conn.execute("SELECT COUNT(*) FROM accounts WHERE enabled=1").fetchone()[0]
logger.info("========== AI Balance Monitor 启动 ==========")
logger.info("端口 %s | 全局间隔 %ss | 重试 %s | 超时 %ss | 并发 %s", cfg.port, cfg.global_interval_seconds, cfg.retry_count, cfg.timeout_seconds, cfg.max_workers)
logger.info("Telegram 提醒: %s", tg)
logger.info("内置平台: %s", ", ".join(p["name"] for p in list_providers()))
logger.info("账号: %s 个(启用 %s| 数据库: %s", total, enabled, db.DB_PATH)
logger.info("面板地址: http://127.0.0.1:%s", cfg.port)
uvicorn.run(app, host="0.0.0.0", port=cfg.port, log_level="warning")