Module: Loggr

Defined in:
lib/loggr-rb.rb,
lib/loggr-rb/config.rb,
lib/loggr-rb/events.rb,
lib/loggr-rb/catcher.rb,
lib/loggr-rb/railtie.rb,
lib/loggr-rb/version.rb,
lib/loggr-rb/logclient.rb,
lib/loggr-rb/logfactory.rb,
lib/loggr-rb/exceptiondata.rb,
lib/loggr-rb/integration/tester.rb

Defined Under Namespace

Modules: Integration Classes: Catcher, Config, DataType, Event, Events, ExceptionData, FluentEvent, LogClient, LogEventJob, LogFactory, Railtie, TrackUserJob

Constant Summary collapse

PROTOCOL_VERSION =
5
CLIENT_NAME =
'loggr-rb-gem'
ENVIRONMENT_FILTER =
[]
VERSION =
'1.0.7'

Class Method Summary collapse

Class Method Details

.clear!Object



55
56
57
# File 'lib/loggr-rb.rb', line 55

def self.clear!
  Thread.current[:loggr_context] = nil
end

.configure(api_key) ⇒ Object



24
25
26
# File 'lib/loggr-rb.rb', line 24

def self.configure(api_key)
  Loggr::Config.api_key = api_key
end

.context(hash = {}) ⇒ Object



59
60
61
62
63
# File 'lib/loggr-rb.rb', line 59

def self.context(hash = {})
  Thread.current[:loggr_context] ||= {}
  Thread.current[:loggr_context].merge!(hash)
  self
end

.handle(exception, request = nil) ⇒ Object



28
29
30
# File 'lib/loggr-rb.rb', line 28

def self.handle(exception, request=nil)
  Loggr::Catcher.handle(exception, request)
end

.loggerObject



20
21
22
# File 'lib/loggr-rb.rb', line 20

def self.logger
  ::Loggr::LogFactory.logger
end

.rescue(name = nil, context = nil, &block) ⇒ Object



32
33
34
35
36
37
38
39
40
41
# File 'lib/loggr-rb.rb', line 32

def self.rescue(name=nil, context=nil, &block)
  begin
    self.context(context) unless context.nil?
    block.call
  rescue Exception => e
    Loggr::Catcher.handle(e,name)
  ensure
    self.clear!
  end
end

.rescue_and_reraise(name = nil, context = nil, &block) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/loggr-rb.rb', line 43

def self.rescue_and_reraise(name=nil, context=nil, &block)
  begin
    self.context(context) unless context.nil?
    block.call
  rescue Exception => e
    Loggr::Catcher.handle(e,name)
    raise(e)
  ensure
    self.clear!      
  end
end