前端:日誌頁在預設設定下自我說明為什麼是空的 - #555
Merged
Merged
Conversation
The admin logs page showed a bare "No log files are available." whenever listLogs returned nothing. That happens for every logger whose log_file.type is stderr/stdout/none (the default is stderr), because listLogFilesForSource only lists filename and filename_rotate sources. The page gave no reason and no next step, so a config with only stderr loggers looked broken. Add a self-explanatory empty state: alongside the existing message, a hint that only file-type loggers appear here and that the fix is to set log_file.type to filename_rotate (or filename) and reload. The wording also covers the "file logging configured but nothing written yet" case, so it does not falsely claim every empty list is stderr. The missingForDate branch (a browsable source with no file for the selected date) is untouched and stays a distinct message; a test now pins both. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013XCzsYbF6D7omYdwXJhQJ2
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7601613212
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The hint told every empty listing to set a file log type, but an empty listing also happens for a correctly configured filename_rotate/filename logger that has not written its first file yet (listRotatedLogFiles returns empty when the dir is absent; listNamedLogFile when the file is absent). Reword so configuring a file type is conditional and the not-yet-written case is named, instead of telling already-correct deployments they are misconfigured. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013XCzsYbF6D7omYdwXJhQJ2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
問題
打開
/admin/logs,只要listLogs()回空陣列,頁面就只顯示一句adminLogs.empty(「目前沒有可用的日誌檔。」),不說明為什麼空、也不說怎麼讓它不空。成因在
internal/logutil/logfile.go的listLogFilesForSource(現於logfile.go:178,ticket 引用的:138是舊行號,但邏輯一致):只處理filename與filename_rotate兩種型別,其餘一律回空清單。而LogFileType的預設值(空字串)就是 stderr。換句話說,任何沒有明確把log_file.type設成檔案型別的 logger,在這個頁面上等於不存在 —— 只有 stderr logger 的設定(例如桌面版、或shelves[0].logger有設但app_conf.logger沒設的情況)看起來就像壞掉。改法
只動前端,把空狀態改成能自我說明。
AdminLogsPage.vue在logs.length === 0時,除了原本的訊息,再多一行emptyHint:說明只有寫入檔案(log_file.type為filename_rotate或filename)的 logger 會列在這裡,下一步是把型別改成檔案型別後重新載入。en / zh-Hant 兩份 locale 同步新增這個 key。措辭刻意同時涵蓋「全部 logger 都是 stderr」與「已設檔案型別但還沒寫入任何日誌」兩種情況,不會武斷地宣稱每個空清單都是 stderr 造成的。
選這一層而不是改 API:ticket 另提「讓
GET /api/logs順便回報有哪些來源與各自型別」的做法,那更完整,但會動到GET /api/logs的回應形狀(公開 API 合約,屬相容性敏感),對一張 P3 而言超出必要範圍。本 PR 以最小面積滿足驗收;列舉來源留作後續 ticket(見下)。驗收
AdminLogsPage.vue的空狀態現在渲染empty+emptyHint(含 stderr 原因與log_file.type下一步)。新測試explains why the list is empty and how to fix it instead of a bare message斷言頁面文字同時包含stderr與log_file.type。missingForDate) — 該分支未改動;新測試distinguishes an empty list from a browsable source with no file for the date斷言此時不出現.empty-state,而是保留missingForDate警告。檢查
已跑(Node v22.22.2):
npm --prefix frontend test— 131 檔 / 1292 測試全過(含新增 2 例與 locale key 同步檢查)npm --prefix frontend run build(vue-tsc + Vite)— 通過npm --prefix frontend run check-boundaries— OKnpm --prefix frontend run check-licenses— OK未跑:Go 三個模組的測試與 lint、e2e。本次為純前端改動(Vue 模板 / 樣式 / i18n / 單元測試),未觸及任何 Go 檔,故不涉及 Go 或伺服器合約門檻。
後續建議(另開 ticket,不在本 PR 範圍)
ticket 提到的「列舉來源與型別」做法,可解決使用者根本不知道有哪些 logger 存在的問題,並能區分「stderr 來源」與「沒寫入」。同時也值得處理 ticket 指出的旁支:設定檔最頂層的
logger:(ServiceConf.Logger)永遠不會出現在清單裡,因為collectLogSources走的是*AppConf。這兩者都會改到 API 回應形狀,建議獨立成票評估相容性。Ticket: https://app.notion.com/p/patchouligo/3cb190bf023b810bb6c2de5ad4a594f8
🤖 Generated with Claude Code
Generated by Claude Code