Class: BrainzLab::Rails::CableLogSubscriber

Inherits:
ActiveSupport::LogSubscriber
  • Object
show all
Defined in:
lib/brainzlab/rails/log_subscriber.rb

Overview

ActionCable subscriber for broadcast formatting

Constant Summary collapse

COLORS =
LogFormatter::COLORS

Instance Method Summary collapse

Instance Method Details

#broadcast(event) ⇒ Object



159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/brainzlab/rails/log_subscriber.rb', line 159

def broadcast(event)
  payload = event.payload
  broadcasting = payload[:broadcasting]
  message = payload[:message]

  # Decode the channel name from the gid
  channel_name = decode_broadcasting(broadcasting)

  # Format the message summary
  message_summary = format_message(message)

  output = build_output(channel_name, message_summary, event.duration)
  $stdout.write(output)
end