Skip to content

Feature Request: Suppressing server-side logs in configuration #70

@milkeclair

Description

@milkeclair

Hi, I am trying to use this gem in Rails 8!

I find this gem very useful, but when using it, I frequently see log messages related to Hotwire Spark.

To work around this, I created the following initializer.
However, I was wondering if there are any plans to support server-side log suppression in the gem’s configuration
(or if it can be done in the first place).
If such a setting already exists, please let me know.

Thanks for making a useful gem!

#config/initializers/hotwire_spark.rb

return if !defined?(Hotwire) || !defined?(Hotwire::Spark) || !Hotwire::Spark.enabled?

Hotwire::Spark.cable_server.config.logger = Logger.new(nil)
Hotwire::Spark.cable_server.config.cable = { "adapter" => "async" }

class SilentSpark < ActionController::LogSubscriber
  def start_processing(event)
    return if event.payload[:params][:hotwire_spark]
    super(event)
  end

  def process_action(event)
    return if event.payload[:params][:hotwire_spark]
    super(event)
  end
end

ActionController::LogSubscriber.detach_from :action_controller
SilentSpark.attach_to :action_controller

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions