Node js runtime adds logs as an array of arrays, whilst python stores it as an array. Adjust logs template to handle both

This commit is contained in:
Peter Stockings
2025-09-28 23:02:40 +10:00
parent 99723b4b6b
commit ace9f0a896
2 changed files with 14 additions and 5 deletions

View File

@@ -60,9 +60,13 @@ history_url=url_for('http.history', function_id=function_id)) }}
<!-- Logs --> <!-- Logs -->
<div class="bg-gray-50 rounded-lg p-3 overflow-auto max-h-40"> <div class="bg-gray-50 rounded-lg p-3 overflow-auto max-h-40">
{% for log in invocation.logs %} <pre class="text-sm font-mono text-gray-600 whitespace-pre-wrap">{% if invocation.logs and invocation.logs[0] is iterable and invocation.logs[0] is not string -%}
<div class="text-sm font-mono text-gray-600 py-0.5">{{ log[0] }}</div> {{- invocation.logs | map('join', ' ') | join('\n') -}}
{% endfor %} {%- elif invocation.logs is iterable and invocation.logs is not string -%}
{{- invocation.logs | join('\n') -}}
{%- else -%}
{{- invocation.logs | string -}}
{%- endif -%}</pre>
{% if not invocation.logs %} {% if not invocation.logs %}
<div class="text-sm text-gray-400 italic">No logs available</div> <div class="text-sm text-gray-400 italic">No logs available</div>
{% endif %} {% endif %}

View File

@@ -48,8 +48,13 @@ history_url=url_for('timer.history', function_id=function_id)) }}
<!-- Logs --> <!-- Logs -->
<div class="bg-gray-50 rounded-lg p-3 overflow-auto max-h-40"> <div class="bg-gray-50 rounded-lg p-3 overflow-auto max-h-40">
<pre <pre class="text-sm font-mono text-gray-600 whitespace-pre-wrap">{% if invocation.logs and invocation.logs[0] is iterable and invocation.logs[0] is not string -%}
class="text-sm font-mono text-gray-600 whitespace-pre-wrap">{{ (invocation.logs | map('first')) | join('\n') }}</pre> {{- invocation.logs | map('join', ' ') | join('\n') -}}
{%- elif invocation.logs is iterable and invocation.logs is not string -%}
{{- invocation.logs | join('\n') -}}
{%- else -%}
{{- invocation.logs | string -}}
{%- endif -%}</pre>
{% if not invocation.logs %} {% if not invocation.logs %}
<div class="text-sm text-gray-400 italic">No logs available</div> <div class="text-sm text-gray-400 italic">No logs available</div>
{% endif %} {% endif %}