Module: Raven

Defined in:
lib/raven/linecache.rb,
lib/raven.rb,
lib/raven/rack.rb,
lib/raven/error.rb,
lib/raven/event.rb,
lib/raven/client.rb,
lib/raven/logger.rb,
lib/raven/railtie.rb,
lib/raven/version.rb,
lib/raven/processor.rb,
lib/raven/interfaces.rb,
lib/raven/configuration.rb,
lib/raven/interfaces/http.rb,
lib/raven/interfaces/message.rb,
lib/raven/interfaces/exception.rb,
lib/raven/interfaces/stack_trace.rb,
lib/raven/processors/sanitizedata.rb,
lib/raven/rails/middleware/debug_exceptions_catcher.rb

Overview

A much simpler source line cacher because linecache sucks at platform compat

Defined Under Namespace

Modules: Processor, Rails Classes: Client, Configuration, Error, Event, ExceptionInterface, HttpInterface, Interface, LineCache, Logger, MessageInterface, Rack, Railtie, StacktraceInterface

Constant Summary collapse

VERSION =
"0.3.1"
INTERFACES =
{}

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.clientObject

The client object is responsible for delivering formatted data to the Sentry server. Must respond to #send. See Raven::Client.



19
20
21
# File 'lib/raven.rb', line 19

def client
  @client
end

.configurationObject

The configuration object.

See Also:



36
37
38
# File 'lib/raven.rb', line 36

def configuration
  @configuration ||= Configuration.new
end

Class Method Details

.capture(&block) ⇒ Object

Capture and process any exceptions from the given block, or globally if no block is given

Examples:

Raven.capture do
  MyApp.run
end


69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/raven.rb', line 69

def capture(&block)
  if block
    begin
      block.call
    rescue Error => e
      raise # Don't capture Raven errors
    rescue Exception => e
      self.captureException(e)
      raise
    end
  else
    # Install at_exit hook
    at_exit do
      if $!
        logger.debug "Caught a post-mortem exception: #{$!.inspect}"
        self.captureException($!)
      end
    end
  end
end

.captureException(exception) ⇒ Object



90
91
92
93
# File 'lib/raven.rb', line 90

def captureException(exception)
  evt = Event.capture_exception(exception)
  send(evt) if evt
end

.captureMessage(message) ⇒ Object



95
96
97
98
# File 'lib/raven.rb', line 95

def captureMessage(message)
  evt = Event.capture_message(message)
  send(evt) if evt
end

.configure(silent = false) {|configuration| ... } ⇒ Object

Call this method to modify defaults in your initializers.

Examples:

Raven.configure do |config|
  config.server = 'http://...'
end

Yields:



46
47
48
49
50
51
# File 'lib/raven.rb', line 46

def configure(silent = false)
  yield(configuration)
  self.client = Client.new(configuration)
  report_ready unless silent
  self.client
end

.find_interface(name) ⇒ Object



33
34
35
# File 'lib/raven/interfaces.rb', line 33

def self.find_interface(name)
  INTERFACES[name.to_s]
end

.loggerObject



25
26
27
# File 'lib/raven.rb', line 25

def logger
  @logger ||= Logger.new
end

.register_interface(mapping) ⇒ Object



26
27
28
29
30
31
# File 'lib/raven/interfaces.rb', line 26

def self.register_interface(mapping)
  mapping.each_pair do |key, klass|
    INTERFACES[key.to_s] = klass
    INTERFACES[klass.name] = klass
  end
end

.report_readyObject

Tell the log that the client is good to go



30
31
32
# File 'lib/raven.rb', line 30

def report_ready
  self.logger.info "Raven #{VERSION} ready to catch errors"
end

.send(evt) ⇒ Object

Send an event to the configured Sentry server

Examples:

evt = Raven::Event.new(:message => "An error")
Raven.send(evt)


58
59
60
# File 'lib/raven.rb', line 58

def send(evt)
  @client.send(evt) if @client
end