lib/rorvswild.rb in rorvswild-1.0.1 vs lib/rorvswild.rb in rorvswild-1.1.0

- old
+ new

@@ -1,21 +1,30 @@ require "rorvswild/version" require "rorvswild/location" require "rorvswild/section" require "rorvswild/client" require "rorvswild/plugins" +require "rorvswild/queue" require "rorvswild/agent" module RorVsWild def self.start(config) + @logger = initialize_logger(config[:logger]) @agent = Agent.new(config) + rescue Exception => ex + logger.error(ex) + raise end def self.agent @agent end + def self.logger + @logger ||= Logger.new(STDOUT) + end + def self.measure_code(code) agent ? agent.measure_code(code) : eval(code) end def self.measure_block(name, &block) @@ -26,9 +35,17 @@ agent ? agent.catch_error(extra_details, &block) : block.call end def self.record_error(exception, extra_details = nil) agent.record_error(exception, extra_details) if agent + end + + def self.initialize_logger(destination) + if destination + Logger.new(destination) + elsif defined?(Rails) + Logger.new(Rails.root + "log/rorvswild.log") + end end end if defined?(Rails) require "rorvswild/rails_loader"