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

Fix: NoMethodError - undefined method 'tagged' for #<ActiveSupport::Logger> #716

Merged
merged 6 commits into from
Aug 31, 2017

Conversation

curvo
Copy link
Contributor

@curvo curvo commented Aug 31, 2017

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.

@curvo
Copy link
Contributor Author

curvo commented Aug 31, 2017

screenshot 2017-08-30 18 54 31

Webpacker.logger = ::Rails.logger
if ::Rails.logger.respond_to?(:tagged)
Webpacker.logger = ::Rails.logger
end
Copy link
Contributor

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

Copy link
Member

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?

cattr_accessor(:logger) { ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(STDOUT)) }

Copy link
Contributor

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.

Copy link
Member

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 👍

Copy link
Contributor Author

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.

@gauravtiwari gauravtiwari merged commit fb86ef1 into rails:master Aug 31, 2017
@gauravtiwari
Copy link
Member

thanks 🍰

@curvo curvo deleted the logger-tagged-bug branch September 1, 2017 00:44
@curvo
Copy link
Contributor Author

curvo commented Sep 1, 2017

Happy to contribute!

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.

3 participants