初始提交: LiteAdmin 社区平台
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
{% extends "admin/base.html" %}
|
||||
{% block title %}运行日志 - LiteAdmin{% endblock %}
|
||||
{% block breadcrumb %}<a href="/admin/">控制台</a> / <span>运行日志</span>{% endblock %}
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<h2>运行日志</h2>
|
||||
<div>
|
||||
<form method="get" style="display:flex;gap:8px;align-items:center;">
|
||||
<select name="level" class="form-control" style="width:auto;" onchange="this.form.submit()">
|
||||
<option value="">全部级别</option>
|
||||
<option value="DEBUG" {% if level == 'DEBUG' %}selected{% endif %}>DEBUG</option>
|
||||
<option value="INFO" {% if level == 'INFO' %}selected{% endif %}>INFO</option>
|
||||
<option value="WARNING" {% if level == 'WARNING' %}selected{% endif %}>WARNING</option>
|
||||
<option value="ERROR" {% if level == 'ERROR' %}selected{% endif %}>ERROR</option>
|
||||
<option value="CRITICAL" {% if level == 'CRITICAL' %}selected{% endif %}>CRITICAL</option>
|
||||
</select>
|
||||
<input type="text" name="search" class="form-control" style="width:200px;" placeholder="搜索日志..." value="{{ search or '' }}">
|
||||
<button type="submit" class="btn btn-primary btn-sm">筛选</button>
|
||||
<a href="/admin/logs/" class="btn btn-sm">重置</a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3>日志列表</h3>
|
||||
<span style="font-size:13px;color:var(--text-light);">自动刷新中</span>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="log-viewer" id="logViewer">
|
||||
{% if logs %}
|
||||
{% for log in logs %}
|
||||
<div class="log-entry log-{{ log.level }}">[{{ log.time }}] [{{ log.level }}] [{{ log.module }}] {{ log.message }}</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<div class="log-entry" style="color:#94a3b8;">暂无日志记录</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function refreshLogs() {
|
||||
var level = document.querySelector('select[name="level"]').value || '';
|
||||
var search = document.querySelector('input[name="search"]').value || '';
|
||||
var url = '/admin/api/logs/?level=' + encodeURIComponent(level) + '&search=' + encodeURIComponent(search);
|
||||
fetch(url)
|
||||
.then(function(r) { return r.json(); })
|
||||
.then(function(data) {
|
||||
var viewer = document.getElementById('logViewer');
|
||||
var html = '';
|
||||
data.logs.forEach(function(log) {
|
||||
html += '<div class="log-entry log-' + log.level + '">[' + log.time + '] [' + log.level + '] [' + log.module + '] ' + log.message + '</div>';
|
||||
});
|
||||
if (!html) {
|
||||
html = '<div class="log-entry" style="color:#94a3b8;">暂无日志记录</div>';
|
||||
}
|
||||
viewer.innerHTML = html;
|
||||
viewer.scrollTop = viewer.scrollHeight;
|
||||
});
|
||||
}
|
||||
|
||||
setInterval(refreshLogs, 3000);
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user