-
Notifications
You must be signed in to change notification settings - Fork 46
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
Extend custom logger to allow taking the notifications directly and generate it's own string. #57
base: main
Are you sure you want to change the base?
Conversation
… support custom logger taking the notifications directly We have a custom logger, but in order to inspect the callstack and customize the message, we end up throwing out the notification_str and reaching into Thread.current[:prosopite_notifications] directly to get it. We also have to do our own filtering and cleaning because they haven't been cleaned yet. I'm proposing this change to let the customer logger take the `notifications` keyword that gets the notifications OR a single argument that is the generated string. In support of that, I clean the callstacks before calling the custom logger.
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.
Thank you @technicalpickles! This is really useful :)
I think that an example of getting access to the notifications from the custom logger (from the new notifications
keyword argument) in the README would be helpful too.
Prosopite.custom_logger = MyLogger.new | ||
``` | ||
|
||
Additionally, you can further customize how notifications are displayed by makni ga `warn` method that takes a `notifications` keyword: |
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.
Typo: by makni ga
```ruby | ||
class FancifulLogger | ||
def warn(notifications:) | ||
notification.each do |queries, kaller| |
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.
notification
vs notifications
- the singular form doesn't exist.
class FancifulLogger | ||
def warn(notifications:) | ||
notification.each do |queries, kaller| | ||
# queries is an array of strings of santitized queries |
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.
typo santitized
- however what do you mean by sanitized queries?
I would write this as The SQL queries that constitute the N+1 case
def warn(notifications:) | ||
notification.each do |queries, kaller| | ||
# queries is an array of strings of santitized queries | ||
# kaller is the callstack where it was called, and has been cleaned by Prosopite.backtrace_cleaner |
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.
I think they were called
is more appropriate since we are referring to multiple queries.
@raise ||= false | ||
def clean_notifications(notifications) | ||
notifications.map do |queries, kaller| | ||
kaller = backtrace_cleaner.clean(kaller) |
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.
backtrace_cleaner is also called in the generate_notification_message
- should be removed from there
We have a custom logger, but in order to inspect the callstack and customize the message, we end up throwing out the notification_str and reaching into
Thread.current[:prosopite_notifications]
directly to get it.We also have to do our own filtering and cleaning because they haven't been cleaned yet.
I'm proposing this change to let the customer logger take the
notifications
keyword that gets the notifications OR a single argument that is the generated string. In support of that, I clean the callstacks before calling the custom logger.cc @geshwho who wrote our custom logger. Hoping we can refactor it to be smaller with these changes 😁