Skip to content

Incorrect event name logging with :with option in Wisper event broadcasting #215

@qoosuperman

Description

@qoosuperman

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions