Skip to content

feat(log): add package-level SetLevel to control default logger verbosity - #632

Merged
moonD4rk merged 1 commit into
moonD4rk:mainfrom
drogers0:feat/log-package-setlevel
Aug 17, 2026
Merged

moonD4rk merged 1 commit into
moonD4rk:mainfrom
drogers0:feat/log-package-setlevel

Conversation

@drogers0

@drogers0 drogers0 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds log.SetLevel(v Level) so the package-level logger's threshold can be raised, not only lowered.

  • New SetLevel(v Level) in log/log.go, delegating to the default logger's existing Logger.SetLevel. It is the sibling of SetVerbose (which is now just SetLevel(DebugLevel)).
  • SetVerbose refactored to call SetLevel(DebugLevel) — no behavior change for existing callers.

Why

The package-level logger (log.Info/Warn/Error, used by extraction code throughout the library) defaults to InfoLevel and could only be made louder via SetVerbose. There was no supported way to raise the threshold, so a project embedding HackBrowserData as a Go library had no way to quiet its stderr output. With this, a consumer can call log.SetLevel(log.FatalLevel) to silence everything short of a fatal error — the piece needed to use the browser packages as a library without their logs leaking into the host program's output. Fits the "usable as a library" goal from rfc/001-architecture-refactoring.md.

Test plan

  • go build ./...
  • go vet ./log/...
  • go test ./log/... — pass, incl. new TestSetLevel (asserts FatalLevel suppresses Info/Warn/Error, SetVerbose re-enables Debug) and TestSetLevelInvalidPanics (out-of-range level panics, unchanged from Logger.SetLevel)
  • gofmt -l log/ clean

…sity

The package-level logger (used by log.Info/Warn/Error and by extraction code
throughout the library) could only be made louder, via SetVerbose; there was no
way to raise its threshold. Projects embedding HackBrowserData as a library had
no supported way to quiet its stderr output.

Add SetLevel(v Level), the sibling of SetVerbose, delegating to the default
logger's existing SetLevel. Consumers can now call, e.g., log.SetLevel(log.FatalLevel)
to silence everything short of a fatal error. SetVerbose is refactored to call
SetLevel(DebugLevel); no behavior change for existing callers.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.26%. Comparing base (fa3eb17) to head (bcffe14).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #632      +/-   ##
==========================================
+ Coverage   73.12%   73.26%   +0.14%     
==========================================
  Files          69       69              
  Lines        3215     3217       +2     
==========================================
+ Hits         2351     2357       +6     
+ Misses        640      637       -3     
+ Partials      224      223       -1     
Flag Coverage Δ
unittests 73.26% <100.00%> (+0.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@moonD4rk
moonD4rk requested review from moonD4rk and a lite review from Copilot August 17, 2026 02:34

@moonD4rk moonD4rk left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thx

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a package-level log.SetLevel(Level) entrypoint so library consumers can raise (quiet) the default logger’s threshold, complementing the existing SetVerbose() behavior and improving “usable as a library” ergonomics.

Changes:

  • Introduced log.SetLevel(v Level) that delegates to the default logger’s Logger.SetLevel.
  • Refactored SetVerbose() to call SetLevel(DebugLevel) (no behavioral change).
  • Added unit tests covering SetLevel behavior and invalid-level panics.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
log/log.go Adds package-level SetLevel and refactors SetVerbose to use it.
log/log_test.go Adds tests validating threshold suppression and invalid input panic behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@moonD4rk
moonD4rk merged commit adfb6d9 into moonD4rk:main Aug 17, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants