Skip to content

Commit ffbe605

Browse files
committed
Enable Hash#compact_blank inside ActiveSupport::LogSubscriber
Using ActiveSupport::LogSubscriber#color inside a custom log subscriber causes NoMethodError. ```ruby require "bundler/inline" gemfile(true) do source "https://rubygems.org" gem "activesupport" end require "active_support" class TestLogSubscriber < ActiveSupport::LogSubscriber attach_to :test def hi(event) info(color(event.payload[:message], GREEN)) end private def log_exception(name, e) super raise e end end ActiveSupport::LogSubscriber.logger = ActiveSupport::Logger.new(STDOUT) ActiveSupport::Notifications.instrument("hi.test", message: "Hello!") ``` ``` /rails/activesupport/lib/active_support/log_subscriber.rb:193:in `mode_from': undefined method `compact_blank' for an instance of Hash (NoMethodError) modes = MODES.values_at(*options.compact_blank.keys) ^^^^^^^^^^^^^^ ``` For what it's worth, I have encountered this while using kredis locally, like; ``` $ cd kredis $ bin/console irb(main):001> Kredis.string "mystring" Could not log "meta.kredis" event. NoMethodError: undefined method `compact_blank' for an instance of Hash ```
1 parent 2fa3294 commit ffbe605

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

activesupport/lib/active_support/log_subscriber.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
require "active_support/core_ext/module/attribute_accessors"
44
require "active_support/core_ext/class/attribute"
5+
require "active_support/core_ext/enumerable"
56
require "active_support/subscriber"
67
require "active_support/deprecation/proxy_wrappers"
78

0 commit comments

Comments
 (0)