11require 'rubygems'
22require 'socket'
33require 'securerandom'
4+ require 'digest/md5'
45
56require 'raven/error'
67require 'raven/linecache'
@@ -24,7 +25,8 @@ class Event
2425
2526 attr_reader :id
2627 attr_accessor :project , :message , :timestamp , :time_spent , :level , :logger ,
27- :culprit , :server_name , :release , :modules , :extra , :tags , :context , :configuration
28+ :culprit , :server_name , :release , :modules , :extra , :tags , :context , :configuration ,
29+ :checksum
2830
2931 def initialize ( init = { } )
3032 @configuration = Raven . configuration
@@ -43,6 +45,7 @@ def initialize(init = {})
4345 @user = { }
4446 @extra = { }
4547 @tags = { }
48+ @checksum = nil
4649
4750 yield self if block_given?
4851
@@ -108,6 +111,7 @@ def to_hash
108111 data [ :extra ] = @extra if @extra
109112 data [ :tags ] = @tags if @tags
110113 data [ :user ] = @user if @user
114+ data [ :checksum ] = @checksum if @checksum
111115 @interfaces . each_pair do |name , int_data |
112116 data [ name . to_sym ] = int_data . to_hash
113117 end
@@ -186,10 +190,11 @@ def self.stacktrace_interface_from(int, evt, backtrace)
186190 backtrace = Backtrace . parse ( backtrace )
187191 int . frames = backtrace . lines . reverse . map do |line |
188192 StacktraceInterface ::Frame . new . tap do |frame |
189- frame . abs_path = line . file
190- frame . function = line . method
193+ frame . abs_path = line . file if line . file
194+ frame . function = line . method if line . method
191195 frame . lineno = line . number
192196 frame . in_app = line . in_app
197+ frame . module = line . module_name if line . module_name
193198
194199 if evt . configuration [ :context_lines ] && frame . abs_path
195200 frame . pre_context , frame . context_line , frame . post_context = \
@@ -206,6 +211,7 @@ def self._source_lines(_path, _from, _to)
206211 end
207212
208213 def get_file_context ( filename , lineno , context )
214+ return nil , nil , nil unless Raven ::LineCache . is_valid_file ( filename )
209215 lines = ( 2 * context + 1 ) . times . map do |i |
210216 Raven ::LineCache . getline ( filename , lineno - context + i )
211217 end
@@ -234,7 +240,7 @@ def generate_event_id
234240 ary [ 2 ] = ( ary [ 2 ] & 0x0fff ) | 0x4000
235241 ary [ 3 ] = ( ary [ 3 ] & 0x3fff ) | 0x8000
236242 uuid = "%08x-%04x-%04x-%04x-%04x%08x" % ary
237- Digest ::MD5 . hexdigest ( uuid )
243+ :: Digest ::MD5 . hexdigest ( uuid )
238244 end
239245 end
240246end
0 commit comments