ai_se/DebugLogger.py

26 lines
710 B
Python

import streamlit as st
import subprocess
error_log = []
def log_error(error_message):
#if "error_log" not in st.session_state:
# st.session_state["log_error"] = ""
#if "code_error" in st.session_state:
error_log.append(error_message)
def format_debug_output(output):
pass
#qwen
def format_output(text: bytes) -> str:
return text.decode('utf-8', errors='replace').strip()
def format_error(exc: Exception) -> str:
msg = ""
if hasattr(exc, 'stderr') and exc.stderr:
msg = exc.stderr.decode('utf-8', errors='replace').strip()
if isinstance(exc, subprocess.CalledProcessError):
msg = f"[Exit: {exc.returncode}] {msg}"
return msg or "Execution failed"