# -*- coding: utf-8 -*-
"""查找 v8 日志中任务成功/完成的行。"""
import json
from pathlib import Path
from dotenv import load_dotenv

load_dotenv(Path(__file__).resolve().parents[2] / ".env")
from _env_paths import get_output_path

log_dir = get_output_path("SYSTEM_LOG_ROOT")
raw = json.loads((log_dir / "2026-02-21__etl_run_raw_v8.json").read_text("utf-8"))

error_log = raw.get("error_log", "")
output_log = raw.get("output_log", "")
full = output_log + "\n" + error_log

# 查找包含 DWS_ 和 成功/完成/SUCCESS 的行
for line in full.split("\n"):
    if ("DWS_" in line or "ODS_" in line or "DWD_" in line) and ("成功" in line or "完成" in line or "SUCCESS" in line):
        print(line.strip()[:200])
