feat(miner): add a level-aware logging abstraction for the CLI (#4835)#5550
Conversation
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5550 +/- ##
=======================================
Coverage 94.90% 94.91%
=======================================
Files 569 570 +1
Lines 45260 45325 +65
Branches 14675 14675
=======================================
+ Hits 42955 43020 +65
Misses 1571 1571
Partials 734 734
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ Gittensory review result - approve/merge recommendedReview updated: 2026-07-13 04:40:34 UTC
✅ Suggested Action - Approve/Merge
Review summary Nits — 5 non-blocking
Linked issue satisfactionPartially addressed Review context
Contributor next steps
Signal definitions
[BETA] Chat with GittensoryAsk Gittensory a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://gittensory.aethereal.dev/docs/gittensory-commands 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
Summary
Closes #4835.
The miner CLI had no logging dependency or abstraction at all — every command reached for ad hoc
console.log/console.error, so an operator could neither quiet routine chatter nor turn on verbose diagnostics. This adds a minimal, dependency-light, level-aware logger the CLI configures once at startup and every command can share.lib/logger.js— a level-aware logger over an ordered severity scale (silent < error < warn < info < debug). A logger emits a method only when its severity is at or below the active level;error/warngo to stderr andinfo/debugto stdout, matching the CLI's existing stdout-output / stderr-nudge split. It is fully injectable (streams,now,env) so the level/format logic is pure and unit-testable. Extras: structuredkey=valuefields (sorted, deterministic),child()context loggers, aprettymode with a timestamp + level tag, and a process-wide instance viaconfigureLogger/getLogger.--quiet→error,--verbose→debug,--log-level <silent|error|warn|info|debug>, orGITTENSORY_MINER_LOG_LEVEL. An explicit level wins, then quiet, then verbose, then env, then theinfodefault; an unrecognized value is ignored rather than throwing. No-q/-vshort aliases, since-v/-hare already--version/--helpin the entrypoint.bin/gittensory-miner.jspeels the global logging flags off argv withextractLogOptionsand callsconfigureLoggeronce at startup (so the stripped argv is what command dispatch sees, and every command shares one configured logger viagetLogger). The new flags are documented in--help.Migrating the remaining ad hoc
console.*call sites onto this logger is intentionally left to follow-ups so this PR stays a focused, reviewable abstraction + wiring change.Scope
type(scope): short summaryConventional Commit format, for examplefix(api): restore profile access checks.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Closes #123) — a linked open issue is required for every contributor PR.Validation
git diff --checknpm run typechecknpm run test:coveragelocally;codecov/patchrequires ≥99% coverage of the lines AND branches you changed (aim for 100% on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate.npm audit --audit-level=moderatenpm run build:minerandnpm run miner:env-reference:checkNew/changed behavior is fully unit-tested in
test/unit/miner-logger.test.ts— every branch oflogger.jsis exercised (verified locally via lcov: 54/54 branches, 65/65 lines, 17/17 functions). The only backend files this touches arelib/logger.js(fully covered) and three branch-free help-text lines inlib/cli.js(covered by the existingprintHelptest). Addedlib/logger.jstobuild:miner'snode --checklist and regeneratedpackages/gittensory-miner/docs/env-reference.mdfor the newGITTENSORY_MINER_LOG_LEVELread.Safety
UI Evidencesection below with JPG/JPEG or PNG screenshots. — N/A: this is a CLI/backend change with no visible frontend surface.UI Evidence
N/A — this is a CLI/backend (
packages/gittensory-miner) change with no visible UI, frontend, docs page, or extension surface.Notes
The env-reference doc row (
GITTENSORY_MINER_LOG_LEVEL) is generated bynpm run miner:env-reference, not hand-edited.