-
-
Notifications
You must be signed in to change notification settings - Fork 462
ref(logs): extract attribute compilation logic in Monolog LogsHandler #1929
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
ref(logs): extract attribute compilation logic in Monolog LogsHandler #1929
Conversation
Extracted the array_merge logic for compiling log record attributes into a dedicated protected method `compileAttributes()`. This improves code readability and maintainability by separating concerns and making the attribute compilation logic reusable.
|
Thanks, but the code is fine as is. |
I hope to support custom attributes combination, like: https://github.com/friendsofhyperf/components/blob/9b223569b9ade662f3c811138deb635746f0538c/src/sentry/src/Monolog/LogsHandler.php#L53-L64 |
|
It might be worth adding such "important" information in the PR description then. |
That’s alright, I can handle it by extending a subclass. |
|
In fact, the current design is risky. For example: $record['context'] = ['foo' => 'foo'];
$record['extra'] = ['foo' => 'bar'];
$result = array_merge($record['context'], $record['extra']);
output: ['foo' => 'bar'] |
|
Would you mind restoring the PR? With the added context, it makes sense, and we can get this in. |
But I have already deleted the branch. Can this PR be restored? |
Summary
• Extracted the attribute compilation logic from the
handle()method into a dedicatedcompileAttributes()method• Improves code readability and maintainability by separating concerns
• Makes the attribute compilation logic reusable for future enhancements
Changes
compileAttributes(LogRecord $record): arrayhandle()method to use the new method instead of inline array_mergeTest plan
sentry.originattribute should still be properly added to log recordsNote
Refactors
LogsHandlerto extract log attribute compilation into a reusablecompileAttributes()and updateshandle()to use it, with no behavior change.LogsHandler:protected compileAttributes($record): arraythat mergescontext,extra, and addssentry.origin.handle()to usecompileAttributes($record)instead of inlinearray_merge.Written by Cursor Bugbot for commit 1790af4. This will update automatically on new commits. Configure here.