Skip to content
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

Add useful message for logger silence error #381

Merged

Conversation

rossta
Copy link
Member

@rossta rossta commented Oct 7, 2016

The introduction of the quiet assets middleware assumes that ::Rails.logger responds to #silence. For projects using incompatible logger objects, like Ruby's Logger, a (potentially confusing) NoMethodError is raised in development when config.assets.quiet is enabled.

This change now provides an informative error message to help developers update their configured logger to take advantage of quiet asset logging.

Fixes #376

@rails-bot
Copy link

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @rafaelfranca (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rafaelfranca
Copy link
Member

Is not better to check if the logger respond to silence and raise an exception if not instead of rescue an exception?

@rossta
Copy link
Member Author

rossta commented Oct 7, 2016

Yes, that sounds like a great idea. I'll make that change and see if I can address the build errors.

@matthewd
Copy link
Member

matthewd commented Oct 7, 2016

Is it worth considering just in-lining LoggerSilence instead? It's friendlier for users to call, but doing it manually is not exactly complicated.

@rossta
Copy link
Member Author

rossta commented Oct 7, 2016

Yes, that's another good idea I considered but wasn't sure how it'd be
received. It wouldn't require much code, it'd just be a case of duplicated
functionality. Thoughts?

On Friday, October 7, 2016, Matthew Draper [email protected] wrote:

Is it worth considering just in-lining LoggerSilence instead? It's
friendlier for users to call, but doing it manually is not exactly
complicated.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#381 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAAtmfYsIqBowLmJ9h310cAwr4KjpJQYks5qxsmwgaJpZM4KRNEj
.

Ross Kaffenberger
@rossta

@matthewd
Copy link
Member

matthewd commented Oct 8, 2016

Ah, looking closer, I see LoggerSilence is only as short as it is because it uses local_level, which is also our invention.

Perhaps Rails.logger should guarantee it'll return a "Rails-like" logger interface -- wrapping the originally supplied one if needed. But that seems a separate enterprise.

+1 on respond_to?(:silence) here for now.

Add useful message for logger silence error

Raise logger silence error on respond_to? for quiet assets
@rossta rossta force-pushed the improve_error_message_for_logger_silence branch from 8d316cb to 673fe08 Compare October 8, 2016 05:49
@rossta
Copy link
Member Author

rossta commented Oct 17, 2016

Changes made, let me know if you have any more suggestions.

@rossta
Copy link
Member Author

rossta commented Dec 4, 2016

@rafaelfranca Just checking on this to see if there's anything else I can do to help move it forward. Thanks!

@ioquatix
Copy link

@rafaelfranca we just ran into this issue too.

@ioquatix
Copy link

@tenderlove tenderlove merged commit 1f63487 into rails:master May 13, 2022
@ioquatix
Copy link

Thanks @tenderlove

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.

NoMethodError: undefined method 'silence' for #<Logger:...>
6 participants