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 ```
This commit is contained in:
parent
2fa3294618
commit
ffbe6050b8
@ -2,6 +2,7 @@
|
||||
|
||||
require "active_support/core_ext/module/attribute_accessors"
|
||||
require "active_support/core_ext/class/attribute"
|
||||
require "active_support/core_ext/enumerable"
|
||||
require "active_support/subscriber"
|
||||
require "active_support/deprecation/proxy_wrappers"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user