1
0
mirror of https://github.com/amir20/dozzle.git synced 2025-12-21 13:23:07 +01:00

fix: fixes really big logs being split in Docker that exceeded 16KB (#3946)

This commit is contained in:
Amir Raminfar
2025-06-04 13:54:13 -07:00
committed by GitHub
parent 02c28fd001
commit 252d865460
4 changed files with 20 additions and 10 deletions

View File

@@ -2,9 +2,10 @@
<LogItem :logEntry @click="containers.length > 0 && showDrawer(LogDetails, { entry: logEntry })" class="clickable">
<ul class="space-x-4" @click="preventDefaultOnLinks">
<li v-for="(value, name) in validValues" :key="name" class="inline-flex">
<span class="text-light">{{ name }}=</span><span class="font-bold" v-if="value === null">&lt;null&gt;</span>
<span class="text-light">{{ name }}=</span>
<span class="font-bold" v-if="value === null">&lt;null&gt;</span>
<template v-else-if="Array.isArray(value)">
<span class="font-bold" v-html="JSON.stringify(value)"> </span>
<span class="font-bold" v-html="JSON.stringify(value)"></span>
</template>
<span class="font-bold" v-html="stripAnsi(value.toString())" v-else></span>
</li>

View File

@@ -6,6 +6,7 @@ import (
"encoding/binary"
"errors"
"io"
"strings"
"sync"
"github.com/amir20/dozzle/internal/container"
@@ -52,8 +53,16 @@ func (d *LogReader) Read() (string, container.StdType, error) {
std = container.STDERR
}
return message, std, nil
for !strings.HasSuffix(message, "\n") {
tail, _, err := d.readEvent()
if err != nil {
return "", std, err
}
message += tail[32:]
}
return message, std, nil
}
func (d *LogReader) readEvent() (string, StdType, error) {

View File

@@ -84,16 +84,13 @@ Content-Type: text/html
{"m":"INFO Testing stdout logs...","rm":"INFO Testing stdout logs...","ts":1589396137772,"id":466600245,"l":"info","s":"stdout","c":"123456"}
{"m":"INFO Testing stderr logs...","rm":"INFO Testing stderr logs...","ts":1589396197772,"id":1101501603,"l":"info","s":"stderr","c":"123456"}
/* snapshot: Test_handler_between_dates_with_everything_complex */
{"m":{"msg":"a complex log message"},"rm":"{\"msg\":\"a complex log message\"}","ts":1589396197772,"id":62280847,"l":"unknown","s":"stdout","c":"123456"}
/* snapshot: Test_handler_between_dates_with_fill */
{"m":"INFO Testing stdout logs...","rm":"INFO Testing stdout logs...","ts":1589396137772,"id":466600245,"l":"info","s":"stdout","c":"123456"}
{"m":"INFO Testing stderr logs...","rm":"INFO Testing stderr logs...","ts":1589396197772,"id":1101501603,"l":"info","s":"stderr","c":"123456"}
/* snapshot: Test_handler_download_logs */
INFO Testing logs...
@@ -167,12 +164,15 @@ stdout or stderr is required
/* snapshot: Test_handler_streamLogs_happy */
:ping
data: {"m":"INFO Testing logs...","ts":0,"id":4256192898,"l":"info","s":"stdout","c":"123456"}
data: {"m":"INFO Testing logs...\n","ts":0,"id":3835490584,"l":"info","s":"stdout","c":"123456"}
event: container-event
data: {"name":"container-stopped","host":"localhost","actorId":"123456","time":"<removed>"}
/* snapshot: Test_handler_streamLogs_happy_container_stopped */
:ping
@@ -182,7 +182,7 @@ data: {"name":"container-stopped","host":"localhost","actorId":"123456","time":"
/* snapshot: Test_handler_streamLogs_happy_with_id */
:ping
data: {"m":"INFO Testing logs...","rm":"INFO Testing logs...","ts":1589396137772,"id":1469707724,"l":"info","s":"stdout","c":"123456"}
data: {"m":"INFO Testing logs...","rm":"INFO Testing logs...","ts":1589396137772,"id":2908612274,"l":"info","s":"stdout","c":"123456"}
id: 1589396137772

View File

@@ -36,7 +36,7 @@ func Test_handler_streamLogs_happy(t *testing.T) {
mockedClient := new(MockedClient)
data := makeMessage("INFO Testing logs...", container.STDOUT)
data := makeMessage("INFO Testing logs...\n", container.STDOUT)
now := time.Now()
@@ -80,7 +80,7 @@ func Test_handler_streamLogs_happy_with_id(t *testing.T) {
mockedClient := new(MockedClient)
data := makeMessage("2020-05-13T18:55:37.772853839Z INFO Testing logs...", container.STDOUT)
data := makeMessage("2020-05-13T18:55:37.772853839Z INFO Testing logs...\n", container.STDOUT)
started := time.Date(2020, time.May, 13, 18, 55, 37, 772853839, time.UTC)