feat(log): add structured logging support #311

Merged
fuzzy merged 2 commits from feat/structured-logging into main 2026-07-09 19:50:19 +00:00
Owner

What

Add structured logging support to log.lua:

  • log.stage(name) — build stage progress entry (always visible)
  • log.success(msg) — success messages (clean stderr + structured log)
  • Optional context table param — log.info(msg, { module = "...", pkg = "..." })

Why

Completes Phase 2 logging enhancements. Enables structured log output with enriched context for debugging and traceability.

Changes

  • log.lua: New functions + format_ctx() helper + updated log.write visibility rules
  • build.lua: Uses context param on build start
  • cli.lua: Uses log.success for done/activated/deactivated

Testing

  • luacheck — 0 warnings, 0 errors
  • 56/56 tests pass
  • Functional test: context formatting, stage, success all work correctly

Breaking Changes

None — backward compatible (context param is optional).

Closes #239

## What Add structured logging support to `log.lua`: - `log.stage(name)` — build stage progress entry (always visible) - `log.success(msg)` — success messages (clean stderr + structured log) - Optional context table param — `log.info(msg, { module = "...", pkg = "..." })` ## Why Completes Phase 2 logging enhancements. Enables structured log output with enriched context for debugging and traceability. ## Changes - `log.lua`: New functions + `format_ctx()` helper + updated `log.write` visibility rules - `build.lua`: Uses context param on build start - `cli.lua`: Uses `log.success` for done/activated/deactivated ## Testing - [x] `luacheck` — 0 warnings, 0 errors - [x] 56/56 tests pass - [x] Functional test: context formatting, stage, success all work correctly ## Breaking Changes None — backward compatible (context param is optional). Closes #239
Add log.stage(name) for build stage progress entries.
Add log.success(msg) for success messages (clean stderr + structured log).
Add optional context table param to log.info/warn/error/progress.
Update cli.lua: use log.success for done/activated/deactivated messages.
Update build.lua: demonstrate context with pkg info on build start.

Closes #239, #236, #237, #238
docs(roadmap): mark #239 and sub-tasks completed
All checks were successful
PR Checks / lint-and-test (pull_request) Successful in 5m44s
8bfdd3f163
fuzzy scheduled this pull request to auto merge when all checks succeed 2026-07-09 19:44:52 +00:00
the.auditor left a comment

Review: PR #311 — Structured logging support

Verdict: Approved. Cleanly implements Phase 2 structured logging.

Changes verified

  1. lib/qpkg/log.luaformat_ctx() helper, optional ctx param on all log functions, log.stage(name) for build progress, log.success(msg) for success messages. Backward compatible — ctx defaults to nil.

  2. lib/qpkg/log.lua:84-97log.stage_start/log.stage_done now also write to log file (addresses issue #310).

  3. lib/qpkg/log.lua:48level == "stage" added to stderr visibility rule — build progress always visible.

  4. lib/qpkg/build.lua:197 — Context table { module = "build", pkg = ctx.pkg_id } on build start log.

  5. lib/qpkg/cli.lua:366,693,722log.status("done.\n")log.success("done") (fixes double-newline in log file). io.stderr:write for activate/deactivate → log.success.

  6. ROADMAP2.md#239 and subtasks #236-#238 correctly marked done.

Observations

  1. format_ctx (log.lua:35) uses pairs() — non-deterministic key order. For current usage (single context with 2 keys) this is cosmetic, but sorted keys would produce consistent output if context tables grow.
  2. cli.lua:311-312 "already installed" path still uses log.info (silent without --verbose), as tracked in issue #309.
## Review: PR #311 — Structured logging support **Verdict: Approved.** Cleanly implements Phase 2 structured logging. ### Changes verified 1. **`lib/qpkg/log.lua`** — `format_ctx()` helper, optional `ctx` param on all log functions, `log.stage(name)` for build progress, `log.success(msg)` for success messages. Backward compatible — `ctx` defaults to nil. 2. **`lib/qpkg/log.lua:84-97`** — `log.stage_start`/`log.stage_done` now also write to log file (addresses issue #310). 3. **`lib/qpkg/log.lua:48`** — `level == "stage"` added to stderr visibility rule — build progress always visible. 4. **`lib/qpkg/build.lua:197`** — Context table `{ module = "build", pkg = ctx.pkg_id }` on build start log. 5. **`lib/qpkg/cli.lua:366,693,722`** — `log.status("done.\n")` → `log.success("done")` (fixes double-newline in log file). `io.stderr:write` for activate/deactivate → `log.success`. 6. **`ROADMAP2.md`** — #239 and subtasks #236-#238 correctly marked done. ### Observations 1. `format_ctx` (log.lua:35) uses `pairs()` — non-deterministic key order. For current usage (single context with 2 keys) this is cosmetic, but sorted keys would produce consistent output if context tables grow. 2. `cli.lua:311-312` "already installed" path still uses `log.info` (silent without `--verbose`), as tracked in issue #309.
fuzzy merged commit 8bfdd3f163 into main 2026-07-09 19:50:19 +00:00
fuzzy deleted branch feat/structured-logging 2026-07-09 19:50:19 +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!311
No description provided.