module Akita::HarLogger

Constants

VERSION

Public Class Methods

default_file_name() click to toggle source
# File lib/akita/har_logger.rb, line 136
def self.default_file_name
  @@default_file_name
end
get_queue(out_file_name) click to toggle source

Returns the entry queue for the given file. If an entry queue doesn't already exist, one is created and a HAR writer thread is started for the queue.

# File lib/akita/har_logger.rb, line 150
def self.get_queue(out_file_name)
  queue = nil
  Rails.logger.debug "AKITA: About to acquire entry-queue mutex "\
                     "#{@@entry_queues_mutex} in #{Thread.current}. "\
                     "Self-owned? #{@@entry_queues_mutex.owned?}"
  @@entry_queues_mutex.synchronize {
    begin
      Rails.logger.debug "AKITA: Acquired entry-queue mutex "\
                         "#{@@entry_queues_mutex} in #{Thread.current}."
      if @@entry_queues.has_key?(out_file_name) then
        return @@entry_queues[out_file_name]
      end

      queue = Queue.new
      @@entry_queues[out_file_name] = queue
    ensure
      Rails.logger.debug "AKITA: About to release entry-queue mutex "\
                         "#{@@entry_queues_mutex} in #{Thread.current}."
    end
  }

  WriterThread.new out_file_name, queue
  return queue
end
instrument(config, har_file_name = nil) click to toggle source

Adds HAR-logging instrumentation to a Rails application by adding to the top of the middleware stack.

Params:

config

the Rails::Application::Configuration associated with the Rails application being instrumented.

+har_file_name

the name of the HAR file to be produced. If the file exists, it will be overwritten.

# File lib/akita/har_logger.rb, line 17
def self.instrument(config, har_file_name = nil)
  config.middleware.unshift(Middleware, har_file_name)
end
logException(context, e) click to toggle source

Logs the given exception.

# File lib/akita/har_logger.rb, line 72
def self.logException(context, e)
  Rails.logger.debug "AKITA: Exception while #{context}: #{e.message} "\
                     "(#{e.class.name}) in thread #{Thread.current}"
  e.backtrace.each { |frame|
    Rails.logger.debug "AKITA:   #{frame}"
  }
end