Class: BrainzLab::Rails::ViewLogSubscriber

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

Overview

View rendering subscriber

Instance Method Summary collapse

Instance Method Details

#render_layout(event) ⇒ Object



304
305
306
307
308
309
310
311
312
313
314
315
316
# File 'lib/brainzlab/rails/log_subscriber.rb', line 304

def render_layout(event)
  return unless LogSubscriber.formatter

  request_id = Thread.current[:brainzlab_request_id]
  return unless request_id

  payload = event.payload
  layout = template_name(payload[:identifier])

  LogSubscriber.formatter.render_layout(request_id,
                                        layout: layout,
                                        duration: event.duration)
end

#render_partial(event) ⇒ Object



289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/brainzlab/rails/log_subscriber.rb', line 289

def render_partial(event)
  return unless LogSubscriber.formatter

  request_id = Thread.current[:brainzlab_request_id]
  return unless request_id

  payload = event.payload
  template = template_name(payload[:identifier])

  LogSubscriber.formatter.render_partial(request_id,
                                         template: template,
                                         duration: event.duration,
                                         count: payload[:count])
end

#render_template(event) ⇒ Object



274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/brainzlab/rails/log_subscriber.rb', line 274

def render_template(event)
  return unless LogSubscriber.formatter

  request_id = Thread.current[:brainzlab_request_id]
  return unless request_id

  payload = event.payload
  template = template_name(payload[:identifier])

  LogSubscriber.formatter.render_template(request_id,
                                          template: template,
                                          duration: event.duration,
                                          layout: payload[:layout])
end