feat: 添加系统日志功能,记录运行时错误和AI调用失败,提供日志查看页面
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
<p class="account-menu-meta">在线时长:{{ auth_online_for }}</p>
|
||||
<p class="account-menu-meta">最后活动:{{ auth_last_active_at }}</p>
|
||||
<p class="account-menu-meta">空闲时长:{{ auth_idle_for }}</p>
|
||||
<a class="account-menu-item" href="{{ url_for('system_logs_page') }}" role="menuitem">系统日志</a>
|
||||
<a class="account-menu-item" href="{{ url_for('change_password_page') }}" role="menuitem">修改密码</a>
|
||||
<a class="account-menu-item" href="{{ url_for('logout_page') }}" role="menuitem">退出登录</a>
|
||||
</div>
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
超时(秒)
|
||||
<input type="number" name="timeout" min="5" value="{{ settings.timeout }}">
|
||||
</label>
|
||||
<p class="hint full">若使用较慢模型(如 GLM-5、较大推理模型)生成补货建议超时,可先将这里调到 60-90 秒再重试。</p>
|
||||
<label>
|
||||
低库存阈值
|
||||
<input type="number" name="restock_threshold" min="0" value="{{ settings.restock_threshold }}">
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
<p class="alert">{{ message }}</p>
|
||||
<div class="actions" style="margin-top: 10px;">
|
||||
<a class="btn" href="{{ back_url }}">返回上一页</a>
|
||||
{% if status_code >= 500 %}
|
||||
<a class="btn btn-light" href="{{ url_for('system_logs_page') }}">查看系统日志</a>
|
||||
{% endif %}
|
||||
<button class="btn btn-light" type="button" onclick="history.back()">浏览器返回</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
43
templates/logs.html
Normal file
43
templates/logs.html
Normal file
@@ -0,0 +1,43 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>系统日志</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
|
||||
</head>
|
||||
<body>
|
||||
<header class="hero slim">
|
||||
<div>
|
||||
<h1>系统日志</h1>
|
||||
<p>查看最近运行日志,优先关注 ERROR、WARNING 与 AI 接口失败记录</p>
|
||||
</div>
|
||||
<div class="hero-actions">
|
||||
<a class="btn btn-light" href="{{ url_for('types_page') }}">返回仓库概览</a>
|
||||
<a class="btn btn-light" href="{{ url_for('ai_settings_page') }}">AI参数</a>
|
||||
{% include '_account_menu.html' %}
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main class="container">
|
||||
<section class="panel">
|
||||
<div class="group-title-row">
|
||||
<div>
|
||||
<h2>日志文件</h2>
|
||||
<p class="hint">路径:{{ log_path }}</p>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<a class="btn btn-light" href="{{ url_for('system_logs_page', lines=100) }}">最近100行</a>
|
||||
<a class="btn btn-light" href="{{ url_for('system_logs_page', lines=200) }}">最近200行</a>
|
||||
<a class="btn btn-light" href="{{ url_for('system_logs_page', lines=500) }}">最近500行</a>
|
||||
</div>
|
||||
</div>
|
||||
{% if log_lines %}
|
||||
<pre class="ai-panel-content log-viewer">{{ log_lines | join('\n') }}</pre>
|
||||
{% else %}
|
||||
<p class="hint">当前还没有日志记录。首次出现错误后会自动写入。</p>
|
||||
{% endif %}
|
||||
</section>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -91,7 +91,10 @@
|
||||
<section class="panel ai-panel" id="ai-panel">
|
||||
<div class="ai-panel-head">
|
||||
<h2>AI补货建议</h2>
|
||||
<a class="btn btn-light" href="{{ url_for('ai_settings_page') }}">参数</a>
|
||||
<div class="hero-actions">
|
||||
<a class="btn btn-light" href="{{ url_for('system_logs_page') }}">日志</a>
|
||||
<a class="btn btn-light" href="{{ url_for('ai_settings_page') }}">参数</a>
|
||||
</div>
|
||||
</div>
|
||||
<p class="hint">根据低库存与近30天出库数据,生成可执行补货建议。</p>
|
||||
<button class="btn" id="ai-restock-btn" type="button">生成建议</button>
|
||||
|
||||
Reference in New Issue
Block a user