-
Notifications
You must be signed in to change notification settings - Fork 44
Logging overhaul #1218
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
base: main
Are you sure you want to change the base?
Logging overhaul #1218
Conversation
Claude finished @spuun's task —— View job Code Review for Logging OverhaulI've conducted a comprehensive review of this significant logging overhaul PR. Here's my detailed feedback: ✅ Strengths & Good Design DecisionsArchitecture
Implementation Quality
🔍 Issues & ConcernsCritical Issues1. Memory Management in LogfmtFormat ( @io << ' ' << before_backtrace << '"' << ex.backtrace.join(@io, Config.instance.log_backtrace_separator) << '"'
2. Commented Dead Code ( # @io << before << '"' << ex.class.name << ": " << ex.message << '"'
3. Monkey Patching Risk (
Performance Concerns4. Macro Overhead (
5. Metadata Building (
Code Quality Issues6. Magic Number Usage ( backtrace_id = Time.monotonic.nanoseconds
backtrace_id.to_s(@io, 32)
7. Inconsistent Error Handling
Configuration & Security8. Missing Validation (
📊 Test Coverage AssessmentCritical Gap: The PR description explicitly states "No specs" for this massive change. For a core infrastructure component like logging:
🚀 Performance Recommendations
🔒 Security Considerations
🎯 Migration CompletenessThe migration appears incomplete - found remaining
Overall AssessmentThis is an ambitious and well-architected overhaul that addresses real needs for structured logging. However, it has several critical implementation issues and lacks adequate testing. The monkey-patching approach, while clever, introduces significant maintenance risk. Recommendation: Address the critical issues (especially the |
a9400a7
to
1e7853c
Compare
WHAT is this pull request doing?
An overhaul of our logging code to enable more logging formats and make it configurable.
Depends somewhat on crystal-lang/crystal#16098, but this has been monkey patched for now.
Logging
Before this PR we used
Log
mixed with@log
(instance ofLogger
). This PR will add macros soL.<level>
(aliasLogging
) always is used. If it's used in the context of an instance includingLoggable
(e.g.Queue
), the metadata for the instance will be added to the log.To set an instance's metadata
L.context(meta: "data", foo: "bar")
is used, preferrably in the constructor.The macros will remove the need of using block and metadata is just key-value args to the method
Exceptions are passed as a key value arg:
Formats
This PR introduces three different logging formats:
No matter which format that's used the logging will respect the environment variable JOURNAL_STREAM. If it's set timestamp will be omitted (except for json) and the log level will be logged as journal priority.
Configuration
Three new configuration options are added:
log_backtrace_separator
is only used iflog_single_line
is true.HOW can this pull request be tested?
No specs, run lavin and look at output...