Class: ControllerUsage::Subscriber

Inherits:
ActiveSupport::LogSubscriber
  • Object
show all
Includes:
Config
Defined in:
lib/controller-usage/subscriber.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Config

#log_file

Class Method Details

.attachObject



5
6
7
# File 'lib/controller-usage/subscriber.rb', line 5

def self.attach
  attach_to :action_controller
end

Instance Method Details

#loggerObject



9
10
11
# File 'lib/controller-usage/subscriber.rb', line 9

def logger
  @logger ||= ActiveSupport::BufferedLogger.new(log_file)
end

#start_processing(event) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/controller-usage/subscriber.rb', line 13

def start_processing event
  begin
    payload = event.payload
    logger.info "#{Time.now.tv_sec} #{payload[:controller]}##{payload[:action]}"
  rescue => e
    Rails.logger.warn "ControllerUsage Error: " + e.inspect
  end
end