diff --git a/backend/app/service/container.go b/backend/app/service/container.go index f2ff47108..7767385ec 100644 --- a/backend/app/service/container.go +++ b/backend/app/service/container.go @@ -567,7 +567,7 @@ func (u *ContainerService) ContainerLogs(wsConn *websocket.Conn, container, sinc } command := fmt.Sprintf("docker logs %s", container) if tail != "0" { - command += " -n " + tail + command += " --tail " + tail } if since != "all" { command += " --since " + since diff --git a/frontend/src/components/container-log/index.vue b/frontend/src/components/container-log/index.vue index 3ccd7532e..1afc4b1a9 100644 --- a/frontend/src/components/container-log/index.vue +++ b/frontend/src/components/container-log/index.vue @@ -1,15 +1,18 @@
- + - - - + + + + + + + +
{{ $t('commons.button.watch') }} @@ -134,7 +132,7 @@ watch(logVisiable, (val) => { if (screenfull.isEnabled && !val && !mobile.value) screenfull.exit(); }); const searchLogs = async () => { - if (!Number(logSearch.tail) || Number(logSearch.tail) < 0) { + if (Number(logSearch.tail) < 0) { MsgError(i18n.global.t('container.linesHelper')); return; } @@ -157,7 +155,17 @@ const searchLogs = async () => { }; const onDownload = async () => { - downloadWithContent(logInfo.value, logSearch.container + '-' + dateFormatForName(new Date()) + '.log'); + let msg = + logSearch.tail === 0 + ? i18n.global.t('container.downLogHelper1', [logSearch.container]) + : i18n.global.t('container.downLogHelper2', [logSearch.container, logSearch.tail]); + ElMessageBox.confirm(msg, i18n.global.t('file.download'), { + confirmButtonText: i18n.global.t('commons.button.confirm'), + cancelButtonText: i18n.global.t('commons.button.cancel'), + type: 'info', + }).then(async () => { + downloadWithContent(logInfo.value, logSearch.container + '-' + dateFormatForName(new Date()) + '.log'); + }); }; const onClean = async () => { @@ -209,4 +217,13 @@ defineExpose({ .fullScreen { border: none; } +.tailClass { + width: 20%; + float: left; + margin-left: 20px; +} +.fetchClass { + width: 30%; + float: left; +}