fix(database): Fix missing database logs (#8145)

This commit is contained in:
zhengkunwang 2025-03-13 18:25:01 +08:00 committed by GitHub
parent c2dc38f02f
commit 4ff06401d9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 13 additions and 20 deletions

View file

@ -892,21 +892,13 @@ func collectLogs(params dto.StreamLog, messageChan chan<- string, errorChan chan
errorChan <- fmt.Errorf("failed to get stdout pipe: %v", err) errorChan <- fmt.Errorf("failed to get stdout pipe: %v", err)
return return
} }
stderr, err := dockerCmd.StderrPipe() dockerCmd.Stderr = dockerCmd.Stdout
if err != nil {
errorChan <- fmt.Errorf("failed to get stderr pipe: %v", err)
return
}
if err = dockerCmd.Start(); err != nil { if err = dockerCmd.Start(); err != nil {
errorChan <- fmt.Errorf("failed to start command: %v", err) errorChan <- fmt.Errorf("failed to start command: %v", err)
return return
} }
scanner := bufio.NewScanner(stdout) scanner := bufio.NewScanner(stdout)
lineNumber := 0
for scanner.Scan() { for scanner.Scan() {
lineNumber++
message := scanner.Text() message := scanner.Text()
select { select {
case messageChan <- message: case messageChan <- message:
@ -915,17 +907,10 @@ func collectLogs(params dto.StreamLog, messageChan chan<- string, errorChan chan
return return
} }
} }
if err = scanner.Err(); err != nil { if err = scanner.Err(); err != nil {
errorChan <- fmt.Errorf("scanner error: %v", err) errorChan <- fmt.Errorf("scanner error: %v", err)
return return
} }
errScanner := bufio.NewScanner(stderr)
for errScanner.Scan() {
line := errScanner.Text()
errorChan <- fmt.Errorf("%v", line)
}
if err = dockerCmd.Wait(); err != nil { if err = dockerCmd.Wait(); err != nil {
errorChan <- fmt.Errorf("%v", err) errorChan <- fmt.Errorf("%v", err)
return return

View file

@ -24,7 +24,7 @@
{{ $t('commons.button.clean') }} {{ $t('commons.button.clean') }}
</el-button> </el-button>
</div> </div>
<div class="log-container" ref="logContainer"> <div class="log-container" :style="styleVars" ref="logContainer">
<div class="log-spacer" :style="{ height: `${totalHeight}px` }"></div> <div class="log-spacer" :style="{ height: `${totalHeight}px` }"></div>
<div <div
v-for="(log, index) in visibleLogs" v-for="(log, index) in visibleLogs"
@ -61,8 +61,16 @@ const props = defineProps({
type: String, type: String,
default: '', default: '',
}, },
highlightDiff: {
type: Number,
default: 320,
},
}); });
const styleVars = computed(() => ({
'--custom-height': `${props.highlightDiff || 320}px`,
}));
const logVisible = ref(false); const logVisible = ref(false);
const logContainer = ref<HTMLElement | null>(null); const logContainer = ref<HTMLElement | null>(null);
const logs = ref<string[]>([]); const logs = ref<string[]>([]);
@ -252,7 +260,7 @@ onMounted(() => {
} }
.log-container { .log-container {
height: calc(100vh - 350px); height: calc(100vh - var(--custom-height, 320px));
overflow-y: auto; overflow-y: auto;
overflow-x: auto; overflow-x: auto;
position: relative; position: relative;

View file

@ -86,7 +86,7 @@
</el-row> </el-row>
</el-form> </el-form>
</div> </div>
<ContainerLog v-if="activeName === 'log'" :container="baseInfo.containerID" /> <ContainerLog v-if="activeName === 'log'" :container="baseInfo.containerID" :highlightDiff="350" />
<SlowLog <SlowLog
@loading="changeLoading" @loading="changeLoading"
@refresh="loadBaseInfo" @refresh="loadBaseInfo"

View file

@ -46,7 +46,7 @@
</el-row> </el-row>
</el-form> </el-form>
</div> </div>
<ContainerLog v-if="activeName === 'log'" :container="containerID" /> <ContainerLog v-if="activeName === 'log'" :container="containerID" :highlightDiff="350" />
</template> </template>
</LayoutContent> </LayoutContent>