Skip to content

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

Open
drogers0 wants to merge 1 commit into
moonD4rk:mainfrom
drogers0:feat/log-package-setlevel
Open

feat(log): add package-level SetLevel to control default logger verbosity#632
drogers0 wants to merge 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.

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.

2 participants