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
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/webpacker/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ class Webpacker::Engine < ::Rails::Engine

initializer "webpacker.logger" do
config.after_initialize do |app|
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.

end
end

Expand Down