According to the wiki, logging can be enabled with the following initializer settings:
Initializer for logger setup:
# config/initializers/wisper.rb
Wisper.configure do |config|
config.broadcaster :default, Wisper::Broadcasters::LoggerBroadcaster.new(
Rails.logger,
Wisper::Broadcasters::SendBroadcaster.new
)
end
Code Example:
here's my listener configuration:
# config/initializers/listeners.rb
Rails.application.config.to_prepare do
Wisper.clear if Rails.env.development? || Rails.env.test?
Wisper.subscribe(UserCreatedEventHandler, on: :user_created, with: :call)
end
The event handler and the model publishing the event:
# app/event_handlers/user_created_event_handler.rb
class UserCreatedEventHandler
def self.call(user)
p('created!!!')
end
end
# app/models/user.rb
class User < ApplicationRecord
include Wisper::Publisher
def do_broadcast
broadcast(:user_created, self)
end
end
Triggering the event:
user = User.first
user.do_broadcast
# Observed log message:
# [WISPER] User#1 published call to UserCreatedEventHandler#104080 with User#1
Expected Behavior:
The log message should reflect the actual event name user_created in the output:
# [WISPER] User#1 published user_created to UserCreatedEventHandler#104080 with User#1
Actual Behavior:
The log message incorrectly displays call instead of the event name user_created
I am willing to explore a solution and contribute a fix via a PR.
Please let me know if any other details are required for investigating this issue.
According to the wiki, logging can be enabled with the following initializer settings:
Initializer for logger setup:
Code Example:
here's my listener configuration:
The event handler and the model publishing the event:
Triggering the event:
Expected Behavior: The log message should reflect the actual event name
user_created
in the output:Actual Behavior: The log message incorrectly displays
call
instead of the event nameuser_created
I am willing to explore a solution and contribute a fix via a PR. Please let me know if any other details are required for investigating this issue.