Skip to content

前端:日誌頁在預設設定下自我說明為什麼是空的 - #555

Merged
mudream4869 merged 2 commits into
devfrom
claude/notion-link-review-hwi7g5
Aug 29, 2026
Merged

前端:日誌頁在預設設定下自我說明為什麼是空的#555
mudream4869 merged 2 commits into
devfrom
claude/notion-link-review-hwi7g5

Conversation

@mudream4869

Copy link
Copy Markdown
Member

問題

打開 /admin/logs,只要 listLogs() 回空陣列,頁面就只顯示一句 adminLogs.empty(「目前沒有可用的日誌檔。」),不說明為什麼空、也不說怎麼讓它不空。

成因在 internal/logutil/logfile.golistLogFilesForSource(現於 logfile.go:178,ticket 引用的 :138 是舊行號,但邏輯一致):只處理 filenamefilename_rotate 兩種型別,其餘一律回空清單。而 LogFileType 的預設值(空字串)就是 stderr。換句話說,任何沒有明確把 log_file.type 設成檔案型別的 logger,在這個頁面上等於不存在 —— 只有 stderr logger 的設定(例如桌面版、或 shelves[0].logger 有設但 app_conf.logger 沒設的情況)看起來就像壞掉。

改法

只動前端,把空狀態改成能自我說明。AdminLogsPage.vuelogs.length === 0 時,除了原本的訊息,再多一行 emptyHint:說明只有寫入檔案(log_file.typefilename_rotatefilename)的 logger 會列在這裡,下一步是把型別改成檔案型別後重新載入。en / zh-Hant 兩份 locale 同步新增這個 key。

措辭刻意同時涵蓋「全部 logger 都是 stderr」與「已設檔案型別但還沒寫入任何日誌」兩種情況,不會武斷地宣稱每個空清單都是 stderr 造成的。

選這一層而不是改 API:ticket 另提「讓 GET /api/logs 順便回報有哪些來源與各自型別」的做法,那更完整,但會動到 GET /api/logs 的回應形狀(公開 API 合約,屬相容性敏感),對一張 P3 而言超出必要範圍。本 PR 以最小面積滿足驗收;列舉來源留作後續 ticket(見下)。

驗收

  • 全部 logger 都是 stderr 時,頁面說得出原因與下一步AdminLogsPage.vue 的空狀態現在渲染 empty + emptyHint(含 stderr 原因與 log_file.type 下一步)。新測試 explains why the list is empty and how to fix it instead of a bare message 斷言頁面文字同時包含 stderrlog_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 — OK
  • npm --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

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread frontend/src/i18n/locales/en.ts Outdated
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
@mudream4869
mudream4869 merged commit c9e49d1 into dev Aug 29, 2026
5 checks passed
@mudream4869
mudream4869 deleted the claude/notion-link-review-hwi7g5 branch August 29, 2026 04:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants