Module: Caliper

Defined in:
lib/caliper/rails/append_info.rb,
lib/caliper.rb,
lib/caliper/rack.rb,
lib/caliper/tracer.rb,
lib/caliper/railtie.rb,
lib/caliper/version.rb,
lib/caliper/app_error.rb,
lib/caliper/route_inspector.rb

Overview

add the resolved controller and action to the trace

Defined Under Namespace

Modules: AppError, Rails Classes: Rack, Railtie, RouteInspector, RouteWrapper, Tracer

Constant Summary collapse

VERSION =
"0.0.2"

Class Method Summary collapse

Class Method Details

.configObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/caliper.rb', line 37

def self.config
  if defined? ::Rails
    config_path = ::Rails.root
    env = ::Rails.env
  else
    config_path = File.new("./")
    env = "test"
  end
  begin
    @config ||= YAML.load_file("#{config_path.join("config", "caliper.yml")}")[::Rails.env].symbolize_keys

    Caliper.logger.error "No API Key set in caliper.yml" unless @config[:api_key]

    # set host
    @config[:api_host] = ENV["CALIPER_API_HOST"] || 'http://alpha.caliper.io/'

    @config
  rescue StandardError => e
    Caliper.logger.error "No caliper.yml config file could be found!"
    raise e
  end
end

.loggerObject



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/caliper.rb', line 23

def self.logger
  unless @logger
    # if in Rails use Rails logger
    if defined? ::Rails
      @logger = ::Rails.logger
    else
      @logger = Logger.new(STDOUT)
      @logger.level = Logger::INFO
    end
  end

  @logger
end