123456789_123456789_123456789_123456789_123456789_

Class: ActionView::LogSubscriber

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: ActiveSupport::EventReporter::LogSubscriber
Defined in: actionview/lib/action_view/log_subscriber.rb

Constant Summary

::ActiveSupport::ColorizeLogging - Included

BLACK, BLUE, CYAN, GREEN, MAGENTA, MODES, RED, WHITE, YELLOW

::ActiveSupport::EventReporter::LogSubscriber - Inherited

LEVEL_CHECKS

Class Attribute Summary

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.newLogSubscriber

[ GitHub ]

  
# File 'actionview/lib/action_view/log_subscriber.rb', line 11

def initialize
  @root = nil
  super
end

Class Method Details

.default_logger

[ GitHub ]

  
# File 'actionview/lib/action_view/log_subscriber.rb', line 67

def self.default_logger
  ActionView::Base.logger
end

Instance Method Details

#cache_message(payload) (private)

[ GitHub ]

  
# File 'actionview/lib/action_view/log_subscriber.rb', line 90

def cache_message(payload) # :doc:
  case payload[:cache_hit]
  when :hit
    "[cache hit]"
  when :miss
    "[cache miss]"
  end
end

#from_rails_root(string) (private)

[ GitHub ]

  
# File 'actionview/lib/action_view/log_subscriber.rb', line 72

def from_rails_root(string)
  string = string.sub(rails_root, "")
  string.sub!(VIEWS_PATTERN, "")
  string
end

#rails_root (private)

[ GitHub ]

  
# File 'actionview/lib/action_view/log_subscriber.rb', line 78

def rails_root # :doc:
  @root ||= "#{Rails.root}/"
end

#render_collection(event)

[ GitHub ]

  
# File 'actionview/lib/action_view/log_subscriber.rb', line 44

def render_collection(event)
  identifier = event[:payload][:identifier] || "templates"

  debug do
    message = +"  Rendered collection of #{from_rails_root(identifier)}"
    message << " within #{from_rails_root(event[:payload][:layout])}" if event[:payload][:layout]
    message << " #{render_count(event[:payload])} (Duration: #{event[:payload][:duration_ms].round(1)}ms | GC: #{event[:payload][:gc_ms].round(1)}ms)"
    message
  end
end

#render_count(payload) (private)

[ GitHub ]

  
# File 'actionview/lib/action_view/log_subscriber.rb', line 82

def render_count(payload) # :doc:
  if payload[:cache_hits]
    "[#{payload[:cache_hits]} / #{payload[:count]} cache hits]"
  else
    "[#{payload[:count]} times]"
  end
end

#render_layout(event)

[ GitHub ]

  
# File 'actionview/lib/action_view/log_subscriber.rb', line 36

def render_layout(event)
  info do
    message = +"  Rendered layout #{from_rails_root(event[:payload][:identifier])}"
    message << " (Duration: #{event[:payload][:duration_ms].round(1)}ms | GC: #{event[:payload][:gc_ms].round(1)}ms)"
  end
end

#render_partial(event)

[ GitHub ]

  
# File 'actionview/lib/action_view/log_subscriber.rb', line 25

def render_partial(event)
  debug do
    message = +"  Rendered #{from_rails_root(event[:payload][:identifier])}"
    message << " within #{from_rails_root(event[:payload][:layout])}" if event[:payload][:layout]
    message << " (Duration: #{event[:payload][:duration_ms].round(1)}ms | GC: #{event[:payload][:gc_ms].round(1)}ms)"
    message << " #{cache_message(event[:payload])}" unless event[:payload][:cache_hit].nil?
    message
  end
end

#render_start(event)

[ GitHub ]

  
# File 'actionview/lib/action_view/log_subscriber.rb', line 56

def render_start(event)
  debug do
    payload = event[:payload]

    message = +"  Rendering #{payload[:is_layout] ? "layout " : ""}#{from_rails_root(payload[:identifier])}"
    message << " within #{from_rails_root(payload[:layout])}" if payload[:layout]
    message
  end
end

#render_template(event)

[ GitHub ]

  
# File 'actionview/lib/action_view/log_subscriber.rb', line 16

def render_template(event)
  info do
    message = +"  Rendered #{from_rails_root(event[:payload][:identifier])}"
    message << " within #{from_rails_root(event[:payload][:layout])}" if event[:payload][:layout]
    message << " (Duration: #{event[:payload][:duration_ms].round(1)}ms | GC: #{event[:payload][:gc_ms].round(1)}ms)"
  end
end