Class: ActiveProfiling::ActionController::LogSubscriber

Inherits:
ActiveSupport::LogSubscriber
  • Object
show all
Defined in:
lib/active-profiling/action_controller/log_subscriber.rb

Instance Method Summary collapse

Instance Method Details

#gc_statistics(event) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/active-profiling/action_controller/log_subscriber.rb', line 27

def gc_statistics(event)
  return unless logger &&
    logger.send("#{config.gc_statistics.log_level}?")

  unless event.payload[:report].blank?
    title = event.payload[:title]
    report = self.indent(event.payload[:report])

    logger.send(
      config.gc_statistics.log_level,
      "#{color("GC Statistics: #{title}", YELLOW, true)}\n#{report}"
    )
  end
end

#loggerObject



42
43
44
# File 'lib/active-profiling/action_controller/log_subscriber.rb', line 42

def logger
  ::Rails.logger
end

#profiler_output(event) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/active-profiling/action_controller/log_subscriber.rb', line 4

def profiler_output(event)
  return unless logger &&
    logger.send("#{config.profiler.log_level}?")

  report = self.indent(event.payload[:profiler_output])
  title = event.payload[:title]

  logger.send(
    config.profiler.log_level,
    "#{color("Profiler Output: #{title}", YELLOW, true)}\n#{report}"
  )
end

#profiler_output_to_file(event) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/active-profiling/action_controller/log_subscriber.rb', line 17

def profiler_output_to_file(event)
  return unless logger &&
    logger.send("#{config.profiler.log_level}?")

  logger.send(
    config.profiler.log_level,
    color("Wrote profiling information to #{event.payload[:file_name]}", YELLOW, true)
  )
end