Module: LogSanity::Extensions::ActionCableConnection

Extended by:
ActiveSupport::Concern
Defined in:
lib/log_sanity/extensions/action_cable_connection.rb

Instance Method Summary collapse

Instance Method Details

#close(reason: nil, **args) ⇒ Object



6
7
8
9
# File 'lib/log_sanity/extensions/action_cable_connection.rb', line 6

def close(reason: nil, **args)
  @close_reason = reason
  super
end

#on_close(reason, code) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/log_sanity/extensions/action_cable_connection.rb', line 26

def on_close(reason, code)
  payload = {
    connection_sec: Time.now - @started_at,
    request: request
  }
  payload[:reason] = @close_reason if @close_reason
  ActiveSupport::Notifications.instrument("on_close.action_cable", payload) do
    super
  end
end

#processObject



11
12
13
14
15
16
17
18
# File 'lib/log_sanity/extensions/action_cable_connection.rb', line 11

def process
  payload = { request: request }
  ActiveSupport::Notifications.instrument("process.action_cable", payload) do
    status, _, _ = response = super
    payload[:status] = status==-1 ? 101 : status
    response
  end
end

#reject_unauthorized_connectionObject



20
21
22
23
24
# File 'lib/log_sanity/extensions/action_cable_connection.rb', line 20

def reject_unauthorized_connection
  logger.instance_variable_get(:@logger).silence(Logger::FATAL) do
    super
  end
end