feat(log): consolidate stderr writes into log module #308

Merged
fuzzy merged 2 commits from feat/consolidate-stderr-writes into main 2026-07-09 19:42:27 +00:00
Owner

What

Audit all direct io.stderr:write calls across the codebase and route them through the log module.

Why

Phase 2 logging consolidation. Every module now uses log.* for user-facing output — zero direct stderr writes outside cli.lua command output and log.lua implementation.

Changes

  • log.lua: Add log.stage_start(name) and log.stage_done(ok) for build progress
  • build.lua:201-212: Replace direct stderr writes with log.stage_start/log.stage_done
  • cli.lua:311-314: Replace io.stderr:write with log.info
  • hash.lua/fetch.lua: Already addressed by Phase 1 (error returns instead of stderr writes)

Testing

  • luacheck — 0 warnings, 0 errors
  • 56/56 tests pass

Breaking Changes

None.

Closes #235

## What Audit all direct `io.stderr:write` calls across the codebase and route them through the log module. ## Why Phase 2 logging consolidation. Every module now uses `log.*` for user-facing output — zero direct stderr writes outside `cli.lua` command output and `log.lua` implementation. ## Changes - `log.lua`: Add `log.stage_start(name)` and `log.stage_done(ok)` for build progress - `build.lua:201-212`: Replace direct stderr writes with `log.stage_start`/`log.stage_done` - `cli.lua:311-314`: Replace `io.stderr:write` with `log.info` - `hash.lua`/`fetch.lua`: Already addressed by Phase 1 (error returns instead of stderr writes) ## Testing - [x] `luacheck` — 0 warnings, 0 errors - [x] 56/56 tests pass ## Breaking Changes None. Closes #235
Add log.stage_start/log.stage_done to log.lua for build progress:
- log.stage_start(name) prints stage header, flushes
- log.stage_done(ok) prints ok/fail result

Replace remaining direct io.stderr:write calls:
- build.lua:201-212: use log.stage_start/log.stage_done
- cli.lua:311-314: use log.info for already-installed messages

All hash.lua and fetch.lua direct stderr writes were already
eliminated in Phase 1 error handling work.

Closes #235, #230, #231, #232, #233, #234
docs(roadmap): mark #235 and sub-tasks completed
All checks were successful
PR Checks / lint-and-test (pull_request) Successful in 5m37s
623b8a303a
fuzzy scheduled this pull request to auto merge when all checks succeed 2026-07-09 19:36:52 +00:00
the.auditor left a comment

Review: PR #308 — Consolidate stderr writes into log module

Verdict: Approved. Correctly implements Phase 2 logging consolidation.

Changes verified

  1. lib/qpkg/log.lua:63-74log.stage_start/log.stage_done added. Appropriate use of direct io.stderr:write for real-time progress output.

  2. lib/qpkg/build.lua:205-207io.stderr:write replaced with log.stage_start/log.stage_done. Exact semantic match.

  3. lib/qpkg/cli.luaerrors import removed (no remaining references). io.stderr:write + errors.wrap_not_found replaced with log.info. The old wrap_not_found("package", ..., "already installed") was semantically incorrect (package was found, just installed) — the new message "X is already installed" is more accurate.

  4. ROADMAP2.md#235 and subtasks #230-#234 correctly marked done.

Non-blocking observation

  1. cli.lua:311-312log.info writes to stderr only when log.verbose is true. The old code always showed the "already installed" message. At this point in the function, log.open() hasn't been called yet, so the message is also not written to the log file. Users running qpkg install <pkg> on an already-installed package get no output (exit 0). If the intent is to always notify, consider log.warn (always visible). If silent success is intentional, this is fine as-is.

  2. log.stage_start/log.stage_done write directly to stderr but don't log to file, unlike log.status which does both. Minor inconsistency — consider adding log.write("progress", ...) calls if build progress should appear in log files.

## Review: PR #308 — Consolidate stderr writes into log module **Verdict: Approved.** Correctly implements Phase 2 logging consolidation. ### Changes verified 1. **`lib/qpkg/log.lua:63-74`** — `log.stage_start`/`log.stage_done` added. Appropriate use of direct `io.stderr:write` for real-time progress output. 2. **`lib/qpkg/build.lua:205-207`** — `io.stderr:write` replaced with `log.stage_start`/`log.stage_done`. Exact semantic match. 3. **`lib/qpkg/cli.lua`** — `errors` import removed (no remaining references). `io.stderr:write` + `errors.wrap_not_found` replaced with `log.info`. The old `wrap_not_found("package", ..., "already installed")` was semantically incorrect (package was found, just installed) — the new message `"X is already installed"` is more accurate. 4. **`ROADMAP2.md`** — #235 and subtasks #230-#234 correctly marked done. ### Non-blocking observation 1. `cli.lua:311-312` — `log.info` writes to stderr only when `log.verbose` is true. The old code always showed the "already installed" message. At this point in the function, `log.open()` hasn't been called yet, so the message is also not written to the log file. Users running `qpkg install <pkg>` on an already-installed package get no output (exit 0). If the intent is to always notify, consider `log.warn` (always visible). If silent success is intentional, this is fine as-is. 2. `log.stage_start`/`log.stage_done` write directly to stderr but don't log to file, unlike `log.status` which does both. Minor inconsistency — consider adding `log.write("progress", ...)` calls if build progress should appear in log files.
fuzzy merged commit 623b8a303a into main 2026-07-09 19:42:27 +00:00
fuzzy deleted branch feat/consolidate-stderr-writes 2026-07-09 19:42:27 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thwap/qpkg!308
No description provided.