# -*- coding: utf-8 -*-
"""获取指定 execution_id 的完整日志。"""
import json
import sys
from pathlib import Path

import requests

TOKEN = Path(__file__).parent.joinpath(".monitor_token").read_text().strip()
BASE = "http://localhost:8000"
HEADERS = {"Authorization": f"Bearer {TOKEN}"}

execution_id = "e21e1935-5abf-434f-9984-69c492402db7"

resp = requests.get(f"{BASE}/api/execution/{execution_id}/logs", headers=HEADERS, timeout=30)
print(f"status_code={resp.status_code}")
data = resp.json()
print(f"output_log length: {len(data.get('output_log') or '')}")
print(f"error_log length: {len(data.get('error_log') or '')}")
print("--- output_log ---")
print(data.get("output_log") or "(empty)")
print("--- error_log ---")
print(data.get("error_log") or "(empty)")
