diff --git a/agent/app/service/container.go b/agent/app/service/container.go index 19ab39b89..88d6e1c5d 100644 --- a/agent/app/service/container.go +++ b/agent/app/service/container.go @@ -934,11 +934,9 @@ func (u *ContainerService) DownloadContainerLogs(containerType, container, since if cmd.CheckIllegal(container, since, tail) { return buserr.New("ErrCmdIllegal") } - commandName := "docker" commandArg := []string{"logs", container} if containerType == "compose" { - commandName = "docker compose" - commandArg = []string{"-f", container, "logs"} + commandArg = []string{"compose", "-f", container, "logs"} } if tail != "0" { commandArg = append(commandArg, "--tail") @@ -949,7 +947,7 @@ func (u *ContainerService) DownloadContainerLogs(containerType, container, since commandArg = append(commandArg, since) } - cmd := exec.Command(commandName, commandArg...) + cmd := exec.Command("docker", commandArg...) stdout, err := cmd.StdoutPipe() if err != nil { _ = cmd.Process.Signal(syscall.SIGTERM) diff --git a/frontend/package.json b/frontend/package.json index b8f4b19fb..081212ef8 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -33,6 +33,7 @@ "@vueuse/core": "^8.9.4", "@xterm/addon-fit": "^0.10.0", "@xterm/xterm": "^5.5.0", + "anser": "^2.3.2", "axios": "^1.7.2", "codemirror": "^6.0.1", "crypto-js": "^4.2.0", diff --git a/frontend/src/components/log/compose/index.vue b/frontend/src/components/log/compose/index.vue index 3d5c4a484..6666da114 100644 --- a/frontend/src/components/log/compose/index.vue +++ b/frontend/src/components/log/compose/index.vue @@ -12,7 +12,7 @@ diff --git a/frontend/src/components/log/container/index.vue b/frontend/src/components/log/container/index.vue index 71e018d21..c901f3821 100644 --- a/frontend/src/components/log/container/index.vue +++ b/frontend/src/components/log/container/index.vue @@ -55,6 +55,10 @@ const props = defineProps({ type: String, default: '', }, + resource: { + type: String, + default: '', + }, }); const logVisible = ref(false); @@ -116,6 +120,10 @@ const searchLogs = async () => { MsgError(i18n.global.t('container.linesHelper')); return; } + if (!logSearch.isWatch) { + stopListening(); + return; + } logs.value = []; let url = `/api/v2/containers/search/log?container=${logSearch.container}&since=${logSearch.mode}&tail=${logSearch.tail}&follow=${logSearch.isWatch}`; if (logSearch.compose !== '') { @@ -139,20 +147,26 @@ const searchLogs = async () => { const onDownload = async () => { logSearch.tail = 0; - let msg = i18n.global.t('container.downLogHelper1', [logSearch.container]); + const container = logSearch.compose === '' ? logSearch.container : logSearch.compose; + let resource = container; + if (props.resource) { + resource = props.resource; + } + const containerType = logSearch.compose === '' ? 'container' : 'compose'; + let msg = i18n.global.t('container.downLogHelper1', [resource]); ElMessageBox.confirm(msg, i18n.global.t('commons.button.download'), { confirmButtonText: i18n.global.t('commons.button.confirm'), cancelButtonText: i18n.global.t('commons.button.cancel'), type: 'info', }).then(async () => { let params = { - container: logSearch.container, + container: container, since: logSearch.mode, tail: logSearch.tail, - containerType: 'container', + containerType: containerType, }; let addItem = {}; - addItem['name'] = logSearch.container + '-' + dateFormatForName(new Date()) + '.log'; + addItem['name'] = resource + '-' + dateFormatForName(new Date()) + '.log'; DownloadFile(params).then((res) => { const downloadUrl = window.URL.createObjectURL(new Blob([res])); const a = document.createElement('a'); diff --git a/frontend/src/components/log/custom-hightlight/index.vue b/frontend/src/components/log/custom-hightlight/index.vue index 0e9bd8ce6..4a90d03a4 100644 --- a/frontend/src/components/log/custom-hightlight/index.vue +++ b/frontend/src/components/log/custom-hightlight/index.vue @@ -1,9 +1,11 @@