Class: Crashdesk::Crashlog

Inherits:
Object
  • Object
show all
Defined in:
lib/crashdesk/crashlog.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exception, request, context, options = {}) ⇒ Crashlog

Returns a new instance of Crashlog.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/crashdesk/crashlog.rb', line 9

def initialize(exception, request, context, options = {})
  self.options = options

  # Anatomy of Exception
  self.exception = exception
  self.backtrace = Crashdesk::Backtrace.parse(exception.backtrace || caller)
  self.exception_class = exception.class.name
  self.exception_message = exception.message

  # Environment
  self.environment = Crashdesk::Environment.new(
    :environment_name => options[:environment_name],
    :project_root => config.project_root)

  # Context
  self.context = context
  self.occured_at = Time.now.utc.iso8601

  # How to report?
  self.reporters = options[:reporters] || config.reporters
end

Instance Attribute Details

#backtraceObject

Returns the value of attribute backtrace.



5
6
7
# File 'lib/crashdesk/crashlog.rb', line 5

def backtrace
  @backtrace
end

#contextObject

Returns the value of attribute context.



5
6
7
# File 'lib/crashdesk/crashlog.rb', line 5

def context
  @context
end

#environmentObject

Returns the value of attribute environment.



5
6
7
# File 'lib/crashdesk/crashlog.rb', line 5

def environment
  @environment
end

#exceptionObject

Returns the value of attribute exception.



5
6
7
# File 'lib/crashdesk/crashlog.rb', line 5

def exception
  @exception
end

#exception_classObject

Returns the value of attribute exception_class.



5
6
7
# File 'lib/crashdesk/crashlog.rb', line 5

def exception_class
  @exception_class
end

#exception_messageObject

Returns the value of attribute exception_message.



5
6
7
# File 'lib/crashdesk/crashlog.rb', line 5

def exception_message
  @exception_message
end

#occured_atObject

Returns the value of attribute occured_at.



5
6
7
# File 'lib/crashdesk/crashlog.rb', line 5

def occured_at
  @occured_at
end

#optionsObject

Returns the value of attribute options.



5
6
7
# File 'lib/crashdesk/crashlog.rb', line 5

def options
  @options
end

#reportersObject

Returns the value of attribute reporters.



5
6
7
# File 'lib/crashdesk/crashlog.rb', line 5

def reporters
  @reporters
end

Instance Method Details

#crcObject



53
54
55
# File 'lib/crashdesk/crashlog.rb', line 53

def crc
  backtrace.crc
end

#reportObject



48
49
50
51
# File 'lib/crashdesk/crashlog.rb', line 48

def report
  report_manager = Crashdesk::ReportManager.new(reporters)
  report_manager.process(self)
end

#to_hashObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/crashdesk/crashlog.rb', line 31

def to_hash
  {
    :app_key => Crashdesk.configuration.app_key,
    :hash_id => backtrace.hash_id,
    :crc => backtrace.crc,
    :occured_at => occured_at,

    :environment => environment.to_hash,

    :backtrace => backtrace.to_a,
    :exception_class => self.exception_class,
    :exception_message => self.exception_message,

    :context => context.to_hash
  }
end