21 lines
696 B
Python
21 lines
696 B
Python
"""查看最新 ETL 日志的最后 50 行"""
|
|
import os
|
|
from pathlib import Path
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv(Path(__file__).resolve().parents[2] / ".env")
|
|
log_root = Path(os.environ["LOG_ROOT"])
|
|
|
|
logs = sorted(log_root.glob("*.log"), key=lambda p: p.stat().st_mtime, reverse=True)
|
|
if not logs:
|
|
print("无日志文件")
|
|
else:
|
|
latest = logs[0]
|
|
print(f"最新日志: {latest.name} ({latest.stat().st_size} bytes)")
|
|
print(f"修改时间: {latest.stat().st_mtime}")
|
|
lines = latest.read_text(encoding="utf-8", errors="replace").splitlines()
|
|
print(f"总行数: {len(lines)}")
|
|
print(f"\n--- 最后 60 行 ---")
|
|
for line in lines[-60:]:
|
|
print(line)
|