Goal: Improve all logseq-cli human output for clarity and usability, and write db-worker-node logs to //db-worker-node-YYYYMMDD.log with retention of the most recent 7 logs.
Architecture: Add a dedicated human output formatter with per-command renderers and consistent error messaging in the CLI formatting layer. Add a file-based glogi appender for db-worker-node that writes logs into the graph-specific data directory using dated filenames and retention while keeping console logging behavior explicit and configurable.
Tech Stack: ClojureScript, babashka/cli, lambdaisland.glogi, Node.js fs/path.
Related: Builds on docs/agent-guide/004-logseq-cli-verb-subcommands.md and docs/agent-guide/003-db-worker-node-cli-orchestration.md.
Target: plain text, no ANSI colors. Each command has a stable layout and ordering.
| Command | OK output (human) | Empty output | Notes |
|---|---|---|---|
| graph list | Table with header GRAPH and rows of graph names, followed by Count: N |
Header + Count: 0 |
Data from {:graphs [...]} |
| graph create | Graph created: <graph> |
n/a | Use graph name from action/options |
| graph switch | Graph switched: <graph> |
n/a | Use graph name from action/options |
| graph remove | Graph removed: <graph> |
n/a | Use graph name from action/options |
| graph validate | Graph validated: <graph> |
n/a | Use graph name from action/options |
| graph info | Lines: Graph: <graph>, Created at: <relative time>, Schema version: <v> |
n/a | Use :logseq.kv/* data; show - if missing; Created at should use the same human-friendly relative format as list outputs |
| server list | Table with header REPO STATUS HOST PORT PID, rows for servers, followed by Count: N |
Header + Count: 0 |
Data from {:servers [...]} |
| server status/start/stop/restart | Server <status>: <repo> + details line Host: <host> Port: <port> when available |
n/a | Use :status keyword where present |
| list page/tag/property | Table with header (fields vary by command) and rows, followed by Count: N |
Header + Count: 0 |
Defaults: page/tag/property ID TITLE UPDATED-AT CREATED-AT (ID uses :db/id); if :db/ident present, include IDENT column |
| add block | Added blocks: <count> (repo: <repo>) |
n/a | Count = number of blocks submitted |
| add page | Added page: <page> (repo: <repo>) |
n/a | |
| remove block | Removed block: <block-id> (repo: <repo>) |
n/a | Prefer UUID if available |
| remove page | Removed page: <page> (repo: <repo>) |
n/a | |
| search | Table with header TYPE TITLE/CONTENT UUID UPDATED-AT CREATED-AT, rows in stable order, followed by Count: N |
Header + Count: 0 |
For block rows use content snippet; for tag/property rows omit timestamps |
| show (text) | Raw tree text with :db/id as first column, trimmed |
n/a | Tree lines should be prefixed by :db/id followed by the tree glyphs. Example:id1 block1id2 ├── b2id3 │ └── b3id4 ├── b4id5 │ ├── b5id6 │ │ └── b6id7 │ └── b7id8 └── b8If a block title spans multiple lines, show the first line on the tree line and indent the remaining lines under the glyph column. Example: 168 Jan 18th, 2026169 ├── b1173 ├── aaaxx174 ├── block-line1│ block-line2175 └── ccccFor `--format json |
| errors | Error (<code>): <message> + optional Hint: <hint> line |
n/a | Ensure error codes are stable and consistent |
The current logseq-cli human output is mostly raw pr-str output, which is hard to read and inconsistent across commands. Users need clearer, command-specific summaries, stable table formats, and more helpful error messages for CLI usage. The db-worker-node process currently logs only to console, but operational debugging requires a per-graph log file stored under the data directory with simple retention.
I will add unit tests for human output formatting functions to ensure stable, readable rendering for each command result shape. I will add unit tests for error formatting to ensure consistent human output for common failure cases. I will add an integration test that starts db-worker-node and verifies that a log file is created at //db-worker-node-YYYYMMDD.log. I will add an integration test that exercises a log-producing db-worker-node action and asserts the log file contains the expected log entries. I will follow @test-driven-development for all behavior changes. NOTE: I will write all tests before I add any implementation behavior.
The CLI outputs structured results and the formatter converts them into human-friendly text based on the command and payload. The db-worker-node daemon configures glogi to append to a per-graph log file under the repo-specific data directory.
ASCII diagram:
+-----------------+ format-result +------------------------+ | logseq-cli | --------------------> | human output formatter | | result payloads | <-------------------- | command renderers | +-----------------+ +------------------------+
+------------------+ glogi appender +-------------------------------------+ | db-worker-node | -----------------> | //db-worker-node-YYYYMMDD.log | +------------------+ +-------------------------------------+
The repo name contains characters that change the pool directory name, so the log file path must use worker-util/get-pool-name consistently. The data directory is on a filesystem without write permissions, which should surface a clear error message and non-zero exit code. Multiple db-worker-node instances for different repos should not overwrite each other’s log files. The log file should be created even if no requests are served yet and only startup logs are emitted. Human output should remain stable when list results are empty or fields are missing. The human formatter should avoid printing large nested maps by default for search or show results.
Run a focused unit test during the red phase.
bb dev:test -v logseq.cli.format-test/test-human-output-list
Expected output includes a failing assertion and exits with a non-zero status code.
Run the db-worker-node log integration test in the green phase.
bb dev:test -v frontend.worker.db-worker-node-test/test-log-file-created
Expected output includes 0 failures and 0 errors.
Run the full lint and unit test suite when all changes are complete.
bb dev:lint-and-test
Expected output includes successful linting and tests with exit code 0.
I will validate human output formatting by asserting on complete rendered strings for representative payloads instead of inspecting internal formatting helpers. I will validate db-worker-node logging by checking file existence, dated filename format, and that only the most recent 7 log files remain after multiple startups. I will assert that a known log event is present after a startup or invoke action.
Should the human output include color or ANSI styling, or should it remain plain text for maximal portability. Answer: Remain plain text for maximal portability. Should db-worker-node log to both console and file, or file-only to avoid duplicate logs in CLI output. Answer: File-only to avoid duplicate logs in CLI output. Is log rotation or size management required for db-worker-node.log, or is simple append-only acceptable. Answer: Use dated log filenames and keep only the most recent 7 log files.