Class: Bugsnag::Breadcrumbs::Breadcrumb

Inherits:
Object
  • Object
show all
Defined in:
lib/bugsnag/breadcrumbs/breadcrumb.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type, meta_data, auto) ⇒ Breadcrumb

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Creates a breadcrumb

This will not have been validated, which must occur before this is attached to a report

Parameters:

  • name (String)

    the breadcrumb name

  • type (String)

    the breadcrumb type from Bugsnag::Breadcrumbs::VALID_BREADCRUMB_TYPES

  • meta_data (Hash, nil)

    a hash containing strings, numbers, or booleans, or nil

  • auto (Symbol)

    set to ‘:auto` if the breadcrumb is automatically generated



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/bugsnag/breadcrumbs/breadcrumb.rb', line 29

def initialize(name, type, , auto)
  @should_ignore = false
  self.name = name
  self.type = type
  self. = 

  # Use the symbol comparison to improve readability of breadcrumb creation
  @auto = auto == :auto

  # Store it as a timestamp for now
  @timestamp = Time.now.utc
end

Instance Attribute Details

#autoBoolean (readonly)

Returns set to ‘true` if the breadcrumb was automatically generated.

Returns:

  • (Boolean)

    set to ‘true` if the breadcrumb was automatically generated



13
14
15
# File 'lib/bugsnag/breadcrumbs/breadcrumb.rb', line 13

def auto
  @auto
end

#meta_dataHash?

Returns metadata hash containing strings, numbers, or booleans, or nil.

Returns:

  • (Hash, nil)

    metadata hash containing strings, numbers, or booleans, or nil



10
11
12
# File 'lib/bugsnag/breadcrumbs/breadcrumb.rb', line 10

def 
  @meta_data
end

#nameString

Returns the breadcrumb name.

Returns:

  • (String)

    the breadcrumb name



4
5
6
# File 'lib/bugsnag/breadcrumbs/breadcrumb.rb', line 4

def name
  @name
end

#timestampTime (readonly)

Returns a Time object referring to breadcrumb creation time.

Returns:

  • (Time)

    a Time object referring to breadcrumb creation time



16
17
18
# File 'lib/bugsnag/breadcrumbs/breadcrumb.rb', line 16

def timestamp
  @timestamp
end

#typeString

Returns the breadcrumb type.

Returns:

  • (String)

    the breadcrumb type



7
8
9
# File 'lib/bugsnag/breadcrumbs/breadcrumb.rb', line 7

def type
  @type
end

Instance Method Details

#ignore!Object

Flags the breadcrumb to be ignored

Ignored breadcrumbs will not be attached to a report



46
47
48
# File 'lib/bugsnag/breadcrumbs/breadcrumb.rb', line 46

def ignore!
  @should_ignore = true
end

#ignore?True?

Checks if the ‘ignore!` method has been called

Ignored breadcrumbs will not be attached to a report

Returns:

  • (True)

    if ‘ignore!` has been called

  • (nil)

    if ‘ignore` has not been called



57
58
59
# File 'lib/bugsnag/breadcrumbs/breadcrumb.rb', line 57

def ignore?
  @should_ignore
end

#to_hHash

Outputs the breadcrumb data in a formatted hash

These adhere to the breadcrumb format as defined in the Bugsnag error reporting API

Returns:

  • (Hash)

    Hash representation of the breadcrumb



67
68
69
70
71
72
73
74
# File 'lib/bugsnag/breadcrumbs/breadcrumb.rb', line 67

def to_h
  {
    :name => @name,
    :type => @type,
    :metaData => @meta_data,
    :timestamp => @timestamp.iso8601
  }
end