Class: Raygun::Breadcrumbs::Store

Inherits:
Object
  • Object
show all
Defined in:
lib/raygun/breadcrumbs/store.rb

Class Method Summary collapse

Class Method Details

.any?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/raygun/breadcrumbs/store.rb', line 46

def self.any?
  stored != nil && stored.length > 0
end

.clearObject



10
11
12
# File 'lib/raygun/breadcrumbs/store.rb', line 10

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

.initializeObject



6
7
8
# File 'lib/raygun/breadcrumbs/store.rb', line 6

def self.initialize
  Thread.current[:breadcrumbs] ||= []
end

.record(message: nil, category: '', level: :info, timestamp: Time.now.utc.to_i, metadata: {}, class_name: nil, method_name: nil, line_number: nil) ⇒ Object

Raises:

  • (ArgumentError)


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/raygun/breadcrumbs/store.rb', line 18

def self.record(
  message: nil,
  category: '',
  level: :info,
  timestamp: Time.now.utc.to_i,
  metadata: {},
  class_name: nil,
  method_name: nil,
  line_number: nil
)
  raise ArgumentError.new('missing keyword: message') if message == nil
  crumb = Breadcrumb.new

  crumb.message = message
  crumb.category = category
  crumb.level = level
  crumb. = 
  crumb.timestamp = timestamp
  crumb.type = 'manual'

  caller = caller_locations[1]
  crumb.class_name = class_name
  crumb.method_name = method_name || caller.label
  crumb.line_number = line_number || caller.lineno

  Thread.current[:breadcrumbs] << crumb if should_record?(crumb)
end

.storedObject



14
15
16
# File 'lib/raygun/breadcrumbs/store.rb', line 14

def self.stored
  Thread.current[:breadcrumbs]
end

.take_until_size(size) ⇒ Object



50
51
52
53
54
55
56
57
58
# File 'lib/raygun/breadcrumbs/store.rb', line 50

def self.take_until_size(size)
  breadcrumb_size = 0

  stored.reverse.take_while do |crumb|
    breadcrumb_size += crumb.size

    breadcrumb_size < size
  end.reverse
end