-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(logging): replace logrus with slog #158
base: main
Are you sure you want to change the base?
Conversation
In a daring move of modernization, replaced the seasoned logrus with the innovative slog across the codebase. This switch isn't just about jumping on new tech but also allows dynamic log level changes at runtime. In case anyone misses the old logs, they have been safely shipped to a retirement island with a smile.
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors Tarmac’s logging implementation by replacing Logrus with the standard library’s slog. The changes update logger initialization, custom log level handling (including a new TRACE level), and adjust all logging calls and documentation accordingly.
- Switched from logrus to slog for structured logging.
- Introduced a custom TRACE log level (LevelTrace) and updated logger initialization and dynamic level updates.
- Revised logging in application, server, and CLI startup code as well as updated documentation and configuration defaults.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
pkg/app/app.go | Refactored logger initialization, dynamic log level updates, and handler recreation using slog. |
pkg/app/slogadapter.go | Added a new adapter to integrate slog with the logging interface. |
docs/running-tarmac/logging.md | Updated logging documentation to reflect the slog based implementation and available log format options. |
docs/running-tarmac/configuration.md | Added configuration details for selecting text log format. |
cmd/tarmac/main.go | Updated main CLI to use slog instead of logrus for logging. |
pkg/app/server.go | Replaced logrus-based logging calls with slog equivalents. |
Comments suppressed due to low confidence (2)
pkg/app/app.go:128
- [nitpick] Consider defining a named constant (e.g. LevelDisabled) for 'slog.LevelError + 4' instead of using a magic number to improve clarity.
logLevel.Set(slog.LevelError + 4) // Higher than Error to disable most logging
pkg/app/slogadapter.go:42
- Consider logging using the custom TRACE level directly (for example, by calling l.logger.Log(context.Background(), LevelTrace, fmt.Sprint(args...))) instead of using Debug with an extra field.
l.logger.Debug(fmt.Sprint(args...), "level", "TRACE")
Ah, the art of whitespace—so elusive, yet so essential. This update wrangles those mischievous spaces back into line. Remember, even logs need a tidy home!
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #158 +/- ##
==========================================
- Coverage 79.88% 74.12% -5.77%
==========================================
Files 14 15 +1
Lines 1775 1905 +130
==========================================
- Hits 1418 1412 -6
- Misses 278 417 +139
+ Partials 79 76 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Replaced some log level logic with a more dynamic approach. Added custom log levels because sometimes default ones just aren't dramatic enough.
This change introduces a dynamic approach for setting and managing log levels in the application, allowing more granular control over logging behavior. - Added custom log level names for increased clarity. - Implemented dynamic log level management based on configuration flags. - Enhanced the logging adapter for unified trace handling. With these tweaks, logging should be both a utility and a source of endless delight.
Simplified the process by removing the middle-logman. Now each log stands on its own, shining brightly in the TRACE level spotlight!
This code was "vibe coded" using Claude Code. It's still a work in progress.