Skip to content

feat(segkit): leveled logger with color + reports artifact (MVP-0.1)#86

Draft
abueide wants to merge 5 commits into
mainfrom
feat/segkit-mvp-0-fundamentals
Draft

feat(segkit): leveled logger with color + reports artifact (MVP-0.1)#86
abueide wants to merge 5 commits into
mainfrom
feat/segkit-mvp-0-fundamentals

Conversation

@abueide

@abueide abueide commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Summary

First slice of MVP-0 (fundamentals): a leveled Rust logger for segkit and the commit/PR conventions we follow going forward. Implements epic 0.1 from notes/segkit-milestones/mvp/mvp-0-fundamentals.md.

Changes

  • Logger (util/log.rs): debug/info/warn/error levels with the shell-matching [LEVEL] [segkit] prefix. debug gated on SEGKIT_DEBUG=1 or DEBUG=1. info/warn/err kept as thin wrappers (no caller churn); hand-rolled, zero new deps; 8 inline unit tests.
  • Dual output: logs go to stderr (diagnostics) color-coded per level on a TTY (NO_COLOR-aware), leaving stdout for program data; every line is also appended uncolored to ${REPORTS_DIR:-reports}/segkit.log as a CI-uploadable historical artifact.
  • Conventions (CONTRIBUTING.md): one type per commit (feat/bug/docs/tests/gen), scope + epic reference in the title, generated/mechanical churn isolated into gen commits, ≤600-line reviewable chunks.
  • Docs (segkit/README.md): logging levels, color behavior, reports artifact, and the stderr/stdout split incl. subprocess stream pass-through.
  • Cleanup (isolated commits): gen = cargo fmt on pre-existing files; bug = clippy lints surfaced by the current pinned toolchain (-D warnings). These unblock CI, which was red on pre-existing debt independent of this change.

Why

Logging and conventions are MVP-0 foundations every later epic builds on. The shell-consistent prefix keeps interleaved CI logs readable across Rust and shell, and the reports/ sink gives CI a uniform place to collect run history. segkit:check (fmt + clippy + 16 tests) is fully green.

Review notes

  • Reads top-to-bottom: docs (conventions) → feat (logger) → docs (README) → gen (fmt churn) → bug (clippy fixes).
  • The gen/bug cleanup commits are pre-existing debt fixed to get this PR's CI green (clippy/rustfmt bump since main's last segkit run); they can be split to a separate branch if you'd prefer 0.1 kept pristine.

🤖 Generated with Claude Code

abueide and others added 5 commits June 16, 2026 16:29
Establish the standard used going forward: one type per commit
(feat/bug/docs/tests/gen), scope, and an epic reference in the title.
Isolate generated/mechanical churn (formatting, lock files, codegen)
into dedicated gen commits, and keep each commit under ~600 lines so
reviewers can skim the noise and read the real work top-to-bottom.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Replace the three-function ANSI logger with debug/info/warn/error
levels mirroring the shell side's "[LEVEL] [segkit] message" prefix so
combined CI logs read uniformly.

- debug is gated on SEGKIT_DEBUG=1 or DEBUG=1, matching the shell flags.
- logs are diagnostics, so they go to stderr (color-coded per level when
  stderr is a terminal), leaving stdout clean for program data; color is
  suppressed when piped/redirected or when NO_COLOR is set.
- every line is also appended, uncolored by construction, to
  ${REPORTS_DIR:-reports}/segkit.log for CI to upload as a historical
  artifact (reuses the REPORTS_DIR root delegate.rs already writes to).
- info/warn/err keep their names as thin wrappers so callers don't churn.
- hand-rolled, zero new dependencies.
- wire the first debug caller into delegate::run so the new level is
  exercised on the delegation hot path.

Inline unit tests cover the prefix format, the uncolored-file invariant,
tag-only coloring, distinct per-level colors, and SEGKIT_DEBUG/DEBUG
gating.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…VP-0.1)

Add segkit/README.md covering the four log levels, the SEGKIT_DEBUG/DEBUG
gate, terminal color behavior (NO_COLOR-aware), the uncolored
reports/segkit.log historical artifact that CI uploads, and the
stderr-for-diagnostics / stdout-for-data split (including subprocess
stream pass-through).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Mechanical `cargo fmt` reflow of files surfaced by the current pinned
rustfmt (1.94) but untouched by this epic. Isolated here so the
formatting churn is skimmable and segkit:fmt:check passes on this branch.
No behavior change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The current pinned clippy (1.94) flags pre-existing code this epic
otherwise leaves alone; segkit:clippy runs with -D warnings, so CI is red
until they're cleared. Fixes, no behavior change:

- collapse nested if / if-let into let-chains (collapsible_if) in
  init_cmd, uninstall, and xcconfig.
- replace XCConfig's inherent to_string with a Display impl
  (inherent_to_string); the single caller's .to_string() still works via
  the blanket ToString impl.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@abueide abueide added the feature New feature or functionality label Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant