From 4ff06401d9a8f5f08345131020d2787b60f715c2 Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Thu, 13 Mar 2025 18:25:01 +0800 Subject: [PATCH] fix(database): Fix missing database logs (#8145) --- agent/app/service/container.go | 17 +---------------- frontend/src/components/log/container/index.vue | 12 ++++++++++-- .../src/views/database/mysql/setting/index.vue | 2 +- .../views/database/postgresql/setting/index.vue | 2 +- 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/agent/app/service/container.go b/agent/app/service/container.go index 937079c0b..c4fc57de2 100644 --- a/agent/app/service/container.go +++ b/agent/app/service/container.go @@ -892,21 +892,13 @@ func collectLogs(params dto.StreamLog, messageChan chan<- string, errorChan chan errorChan <- fmt.Errorf("failed to get stdout pipe: %v", err) return } - stderr, err := dockerCmd.StderrPipe() - if err != nil { - errorChan <- fmt.Errorf("failed to get stderr pipe: %v", err) - return - } + dockerCmd.Stderr = dockerCmd.Stdout if err = dockerCmd.Start(); err != nil { errorChan <- fmt.Errorf("failed to start command: %v", err) return } - scanner := bufio.NewScanner(stdout) - lineNumber := 0 - for scanner.Scan() { - lineNumber++ message := scanner.Text() select { case messageChan <- message: @@ -915,17 +907,10 @@ func collectLogs(params dto.StreamLog, messageChan chan<- string, errorChan chan return } } - if err = scanner.Err(); err != nil { errorChan <- fmt.Errorf("scanner error: %v", err) return } - - errScanner := bufio.NewScanner(stderr) - for errScanner.Scan() { - line := errScanner.Text() - errorChan <- fmt.Errorf("%v", line) - } if err = dockerCmd.Wait(); err != nil { errorChan <- fmt.Errorf("%v", err) return diff --git a/frontend/src/components/log/container/index.vue b/frontend/src/components/log/container/index.vue index eeb86977c..58551018f 100644 --- a/frontend/src/components/log/container/index.vue +++ b/frontend/src/components/log/container/index.vue @@ -24,7 +24,7 @@ {{ $t('commons.button.clean') }} -
+
({ + '--custom-height': `${props.highlightDiff || 320}px`, +})); + const logVisible = ref(false); const logContainer = ref(null); const logs = ref([]); @@ -252,7 +260,7 @@ onMounted(() => { } .log-container { - height: calc(100vh - 350px); + height: calc(100vh - var(--custom-height, 320px)); overflow-y: auto; overflow-x: auto; position: relative; diff --git a/frontend/src/views/database/mysql/setting/index.vue b/frontend/src/views/database/mysql/setting/index.vue index 653c3cd1e..6461ee95b 100644 --- a/frontend/src/views/database/mysql/setting/index.vue +++ b/frontend/src/views/database/mysql/setting/index.vue @@ -86,7 +86,7 @@
- +
- +