Module: Rnotifier

Defined in:
lib/rnotifier.rb,
lib/rnotifier/config.rb,
lib/rnotifier/railtie.rb,
lib/rnotifier/rlogger.rb,
lib/rnotifier/version.rb,
lib/rnotifier/notifier.rb,
lib/rnotifier/event_data.rb,
lib/rnotifier/config_test.rb,
lib/rnotifier/exception_code.rb,
lib/rnotifier/exception_data.rb,
lib/rnotifier/rack_middleware.rb,
lib/rnotifier/parameter_filter.rb

Defined Under Namespace

Classes: Config, ConfigTest, EventData, ExceptionCode, ExceptionData, Notifier, ParameterFilter, RackMiddleware, Railtie, Rlogger

Constant Summary collapse

VERSION =
"0.1.5"

Class Method Summary collapse

Class Method Details

.alert(name, params, tags = {}) ⇒ Object



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

def alert(name, params, tags = {})
  if Rnotifier::Config.valid? && params.is_a?(Hash)
    Rnotifier::EventData.new(name, Rnotifier::EventData::ALERT, params, tags[:tags]).notify 
  end
end

.clear_contextObject



45
46
47
# File 'lib/rnotifier.rb', line 45

def clear_context
  Thread.current[:rnotifier_context] = nil
end

.config {|Rnotifier::Config| ... } ⇒ Object

Yields:



20
21
22
23
# File 'lib/rnotifier.rb', line 20

def config(&block)
  yield(Rnotifier::Config) if block_given?
  Rnotifier::Config.init
end

.context(attrs = {}) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/rnotifier.rb', line 37

def context(attrs = {})
  if Thread.current[:rnotifier_context] 
    Thread.current[:rnotifier_context].merge!(attrs)
  else
    Thread.current[:rnotifier_context] = attrs
  end
end

.event(name, params, tags = {}) ⇒ Object



53
54
55
56
57
# File 'lib/rnotifier.rb', line 53

def event(name, params, tags = {})
  if Rnotifier::Config.valid? && params.is_a?(Hash)
    Rnotifier::EventData.new(name, Rnotifier::EventData::EVENT, params, tags[:tags]).notify 
  end
end

.exception(exception, params = {}) ⇒ Object



49
50
51
# File 'lib/rnotifier.rb', line 49

def exception(exception, params = {})
  Rnotifier::ExceptionData.new(exception, params, {:type => :rescue}).notify
end

.load_config(file) ⇒ Object



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

def load_config(file)
  config_yaml = YAML.load_file(file)

  self.config do |c|
    c.api_key = config_yaml['apikey'] 

    ['environments', 'api_host', 'ignore_exceptions', 'ignore_bots', 'capture_code'].each do |f|
      c.send("#{f}=", config_yaml[f]) if config_yaml[f]
    end
  end
end