reidmorrison/rails_semantic_logger

SemanticLogger is incompatible with ActionCable::Connection because of ActionCable::Connection::TaggedLoggerProxy

kristoph opened this issue · 2 comments

Attempting to include SemanticLogger::Loggable in a class derived from ActionCable::Connection::Base will mean connect on the base class will never be called.

Because ActionCable::Connection implements its own logger, the TaggedLoggerProxy, any attempt to call a logger method with more than the message parameter will fail with "ArgumentError(wrong number of arguments (given 2, expected 0..1))" because such methods do not exist on TaggedLoggerProxy.

This is even true when you manually construct a logger because ActionCable::Connection::Base wraps the logger.

I am using Ruby 3.2 with actioncable-7.1.3.4,

It is unlikely just adding "SemanticLogger::Loggable in a class derived from ActionCable::Connection::Base" would work for Rails. It usually requires far more extensive patching.

Start here to see the patches for the other Rails frameworks and the community contributed fix that may help, to see what changes would be required to support Rails 7.1 Action Cable:

%i[active_record action_controller action_mailer action_view].each do |name|

A Tagged proxy patch:

At some point it will also need its own log subscriber to break down the text messages into log events. Below is an example of how this is being done for Action Controller:

class LogSubscriber < ActiveSupport::LogSubscriber

Is there any way to work around this for ActionCable? Currently this is breaking ActionCable from being able to establish connections in my app