Class: Loggr::Events

Inherits:
Object
  • Object
show all
Defined in:
lib/loggr-rb/events.rb

Class Method Summary collapse

Class Method Details

.create(callback = nil) ⇒ Object



3
4
5
# File 'lib/loggr-rb/events.rb', line 3

def self.create(callback=nil)
  return FluentEvent.new(callback)
end

.create_from_exception(ex, request = nil, callback = nil) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/loggr-rb/events.rb', line 7

def self.create_from_exception(ex, request=nil, callback=nil)
	  source = ""
	  begin
    if !request.nil?
   if !request.parameters.nil?
        controller = request.params['controller'].camelize
     action = request.params['action']
     if !controller.nil?
       source = controller.camelize + "Controller"
          if !action.nil?
            source = source + "#" + action.camelize
          end
        end
   end
 end
	  rescue
	  # no source
	  end
	  ip = ""
	  if !request.nil?
 ip = (request.respond_to?(:remote_ip) ? request.remote_ip : request.ip)
	  end
	  ev = self.create(callback)
  ev.text("Exception '#{ex.message}'")
  ev.tags("error")
  ev.add_tags(ex.class)
  ev.data(Loggr::ExceptionData.format_exception(ex, request))
  ev.datatype(DataType::HTML)
  ev.source(source)
	  ev.geo_ip(ip)
  return ev
end