Skip to content

feat: add optional slog.Logger support for observability#1

Merged
christiangda merged 4 commits intomainfrom
feat.implementation
Feb 14, 2026
Merged

feat: add optional slog.Logger support for observability#1
christiangda merged 4 commits intomainfrom
feat.implementation

Conversation

@christiangda
Copy link
Contributor

Summary

  • Add WithLogger(*slog.Logger) to Provider for optional structured logging with zero overhead when disabled
  • Log component collection results, fallback paths (e.g. system_profiler → ioreg), command execution timing, and errors
  • Thread *slog.Logger through all platform collectors (darwin, linux, windows), executor, and network functions
  • Update all README and doc.go code examples with context.Context parameter
  • Add TestWithLoggerOutput and TestWithoutLoggerNoOutput verification tests

Log Levels

Level What's Logged
Info Component collected, fallback triggered, ID generation lifecycle
Warn Component failed or returned empty value
Debug Command execution details (name, args, duration), raw hardware values

Test plan

  • go build ./... compiles across all platforms
  • go test -v -race -count=1 ./... — all tests pass
  • go vet ./... — no warnings
  • New test verifies log output appears with logger and doesn't appear without
  • Manual test with slog.NewTextHandler and slog.NewJSONHandler

🤖 Generated with Claude Code

christiangda and others added 4 commits February 14, 2026 18:06
Add WithLogger(*slog.Logger) to Provider for optional logging with zero
overhead when disabled. Logs component collection, fallback paths,
command execution timing, and errors at Info/Warn/Debug levels.
Also updates all code examples with context.Context parameter.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@christiangda christiangda self-assigned this Feb 14, 2026
@christiangda christiangda merged commit 059da55 into main Feb 14, 2026
4 checks passed
@christiangda christiangda deleted the feat.implementation branch February 14, 2026 18:31
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.

1 participant

Comments