-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Fix: NoMethodError - undefined method 'tagged' for #<ActiveSupport::Logger> #716
Conversation
Merging in latest updates to webpacker master from rails/webpacker
lib/webpacker/railtie.rb
Outdated
Webpacker.logger = ::Rails.logger | ||
if ::Rails.logger.respond_to?(:tagged) | ||
Webpacker.logger = ::Rails.logger | ||
end |
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.
Could create a tagged logger here to preserve the original logger:
if ::Rails.logger.respond_to?(:tagged)
Webpacker.logger = ::Rails.logger
else
Webpacker.logger = ActiveSupport::TaggedLogging.new(::Rails.logger)
end
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 guess we are already doing this here right?
webpacker/lib/webpacker/instance.rb
Line 2 in 68b9f08
cattr_accessor(:logger) { ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(STDOUT)) } |
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.
That creates a brand new logger. Doesn't wrap your existing Rails.logger
instance.
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.
Ahh I see, totally missed 👍
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.
Makes sense... I'll push that today.
thanks 🍰 |
Happy to contribute! |
This fixes a bug would be found in versions of Rails applications (<v5) that do not have the default logger set up for tagging. The suggested fix is to check for the method before re-assigning the default webpacker logger to be the rails.logger.