Move logs view from dev_panel page to a logs page

This commit is contained in:
Greg Burri 2025-04-26 16:26:35 +02:00
parent 1bb0f05fc0
commit b0f0633338
7 changed files with 110 additions and 42 deletions

View file

@ -10,7 +10,7 @@
{% when Some with (user) %}
<a class="button" href="/recipe/new" >{{ context.tr.t(Sentence::CreateNewRecipe) }}</a>
{% if user.is_admin %}
<a class="button" href="/dev_panel">Dev panel</a>
<a class="button" href="/logs">Logs</a><a class="button" href="/dev_panel">Dev panel</a>
{% endif %}
<a href="/{{ context.tr.current_lang_code() }}/user/edit">
{% if user.name == "" %}

View file

@ -5,37 +5,6 @@
<div class="content" id="dev-panel">
<input type="button" class="button" id="test-toast" value="Test toast">
<input type="button" class="button" id="test-modal-dialog" value="Test modal">
<div type="log">
<ul class="log-files">
{% for f in log.file_names().unwrap() %}
<li class="log-file"><a href="/dev_panel?log_file={{ f }}">{{ f }}</a></li>
{% endfor %}
</ul>
<div class="current-log-file">
{% match log.read_content(current_log_file) %}
{% when Ok(lines) %}
{% for l in lines %}
<div class="line
{%~ if loop.index0 % 2 == 0 %}
even
{% else %}
odd
{% endif %}
" >
{% let l_info = Log::split_line(l) %}
<span class="date-time">{{ l_info.date_time }}</span>
<span class="level {{~ l_info.level }}">{{ l_info.level }}</span>
<span class="thread-name">{{ l_info.thread_name }}</span>
<span class="thread-id">{{ l_info.thread_id }}</span>
<span class="message">{{ l_info.message | linebreaksbr }}</span>
</div>
{% endfor %}
{% when Err(err) %}
Error reading log: {{ err }}
{% endmatch %}
</div>
</div>
</div>
<div id="hidden-templates">

View file

@ -0,0 +1,40 @@
{% extends "base_with_list.html" %}
{% block content %}
<div class="content" id="logs">
<ul class="log-files">
{% for f in log.file_names().unwrap() %}
<li class="log-file
{%~ if current_log_file == f %}
current
{% endif %}
"><a href="/logs?log_file={{ f }}">{{ f }}</a></li>
{% endfor %}
</ul>
<div class="current-log-file">
{% match log.read_content(current_log_file) %}
{% when Ok(lines) %}
{% for l in lines %}
<div class="line
{%~ if loop.index0 % 2 == 0 %}
even
{% else %}
odd
{% endif %}
" >
{% let l_info = Log::split_line(l) %}
<span class="date-time">{{ l_info.date_time }}</span>
<span class="level {{~ l_info.level }}">{{ l_info.level }}</span>
<span class="thread-name">{{ l_info.thread_name }}</span>
<span class="thread-id">{{ l_info.thread_id }}</span>
<span class="message">{{ l_info.message | linebreaksbr }}</span>
</div>
{% endfor %}
{% when Err(err) %}
Error reading log: {{ err }}
{% endmatch %}
</div>
</div>
{% endblock %}