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)
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

View file

@ -24,7 +24,7 @@
{{ $t('commons.button.clean') }}
</el-button>
</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
v-for="(log, index) in visibleLogs"
@ -61,8 +61,16 @@ const props = defineProps({
type: String,
default: '',
},
highlightDiff: {
type: Number,
default: 320,
},
});
const styleVars = computed(() => ({
'--custom-height': `${props.highlightDiff || 320}px`,
}));
const logVisible = ref(false);
const logContainer = ref<HTMLElement | null>(null);
const logs = ref<string[]>([]);
@ -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;

View file

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

View file

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