lib/crash_log.rb in crashlog-1.0.0 vs lib/crash_log.rb in crashlog-1.0.1

- old
+ new

@@ -24,10 +24,11 @@ autoload :SystemInformation, 'crash_log/system_information' LOG_PREFIX = '** [CrashLog]' class << self + attr_accessor :reporter # Sends a notification to CrashLog # # This is the main entry point into the exception sending stack. # @@ -46,16 +47,13 @@ # raise RuntimeError, "This is too dangerous for you" # rescue => e # CrashLog.notify(e, {current_user: current_user}) # end # - # This will try to serialize the current user by calling `as_crashlog_context` or `as_json` - # otherwise it will try `to_s` - # # Returns true if successful, otherwise false - def notify(exception, context = {}) - send_notification(exception, context).tap do |notification| + def notify(exception, data = {}) + send_notification(exception, data).tap do |notification| if notification info "Event sent to CrashLog.io" info "Event URL: http://crashlog.io/locate/#{notification[:location_id]}" if notification.has_key?(:location_id) else error "Failed to send event to CrashLog.io" @@ -84,20 +82,23 @@ # required. def configure(announce = false, &block) if block_given? yield(configuration) + self.reporter = CrashLog::Reporter.new(configuration) + if configuration.valid? if announce.eql?(true) report_for_duty! else info("Configuration updated") end elsif !configuration.invalid_keys.include?(:api_key) error("Not configured correctly. Missing the following keys: #{configuration.invalid_keys.join(', ')}") end end + configuration end # The global configuration object. def configuration @configuration ||= Configuration.new @@ -129,12 +130,15 @@ if live? build_payload(exception, context).deliver! end end - def build_payload(exception, context = {}) + def build_payload(exception, data = {}) Payload.build(exception, configuration) do |payload| - payload.add_context(context) + if context = data.delete(:context) + payload.add_context(context) + end + payload.add_data(data) end end end end