Class: Raygun::Breadcrumbs::Store
- Inherits:
-
Object
- Object
- Raygun::Breadcrumbs::Store
- Defined in:
- lib/raygun/breadcrumbs/store.rb
Class Method Summary collapse
- .any? ⇒ Boolean
- .clear ⇒ Object
- .initialize(with: []) ⇒ Object
- .record(message: nil, category: '', level: :info, timestamp: Time.now.utc.to_i, metadata: {}, class_name: nil, method_name: nil, line_number: nil) ⇒ Object
- .stored ⇒ Object
- .take_until_size(size) ⇒ Object
Class Method Details
.any? ⇒ Boolean
46 47 48 |
# File 'lib/raygun/breadcrumbs/store.rb', line 46 def self.any? stored != nil && stored.length > 0 end |
.clear ⇒ Object
10 11 12 |
# File 'lib/raygun/breadcrumbs/store.rb', line 10 def self.clear Thread.current[:breadcrumbs] = nil end |
.initialize(with: []) ⇒ Object
6 7 8 |
# File 'lib/raygun/breadcrumbs/store.rb', line 6 def self.initialize(with: []) Thread.current[:breadcrumbs] ||= with end |
.record(message: nil, category: '', level: :info, timestamp: Time.now.utc.to_i, metadata: {}, class_name: nil, method_name: nil, line_number: nil) ⇒ Object
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 == nil crumb = Breadcrumb.new crumb. = crumb.category = category crumb.level = level crumb. = crumb. = 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 |
.stored ⇒ Object
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) = 0 stored.reverse.take_while do |crumb| += crumb.size < size end.reverse end |