Skip to content

Commit 937c8ed

Browse files
committed
When expanding log record, preserve newlines
1 parent 17cc0c0 commit 937c8ed

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

dev/config/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ monolog:
5454
error:
5555
type: stream
5656
path: "%kernel.logs_dir%/error.log"
57+
include_stacktraces: true
5758
level: error
5859
channels: [ "!event", "!deprecation" ]
5960
deprecation:

frontend/src/components/LogRecord.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script setup lang="ts">
22
import JsonData from '@/components/json/JsonData.vue';
3+
import Strings from '@/services/Strings.ts';
34
import type LogRecord from '@/models/LogRecord';
45
import {isEmptyJson, prettyFormatJson} from '@/services/JsonFormatter';
56
import {ref} from 'vue';
@@ -23,7 +24,10 @@ function click(value: string) {
2324
<span class="pe-2 text-secondary">{{ logRecord.datetime }}</span>
2425
<span class="text-primary pe-2" v-if="logRecord.channel.length > 0">{{ logRecord.channel }}</span>
2526
<span :class="['pe-2', logRecord.level_class ]">{{ logRecord.level_name }}</span>
26-
<span>{{ logRecord.text }}</span>
27+
28+
<!-- log message -->
29+
<span v-if="!expanded" v-text="logRecord.text.substring(0, 500)"></span>
30+
<span v-if="expanded" v-html="Strings.nl2br(Strings.escapeHtml(logRecord.text))"></span>
2731
</div>
2832
<div class="border-top pt-2 ps-2 mb-2 position-relative" v-bind:class="{'d-block': expanded, 'd-none': !expanded}" v-if="expanded">
2933
<button class="btn btn-outline-secondary slv-btn-raw" @click="styled = !styled">{{ styled ? 'raw' : 'styled' }}</button>

frontend/src/services/Strings.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,15 @@ export default class Strings {
1010

1111
return str;
1212
}
13+
14+
public static nl2br(str: string): string {
15+
return str.replace(/\n/g, '<br/>');
16+
}
17+
18+
public static escapeHtml(str: string): string {
19+
return str
20+
.replace(/&/g, '&amp;')
21+
.replace(/</g, '&lt;')
22+
.replace(/>/g, '&gt;')
23+
}
1324
}

0 commit comments

Comments
 (0)