Sha256: 9487b575f703c3b080d451b5adc9d6af3e6e1c717b79a55034fe9e63479b14b3

Contents?: true

Size: 1.05 KB

Versions: 65

Compression:

Stored size: 1.05 KB

Contents

require 'time'

module Honeybadger
  module Breadcrumbs
    class Breadcrumb
      # Raw breadcrumb data structure
      #
      attr_reader :category, :timestamp
      attr_accessor :message, :metadata, :active

      include Comparable

      def initialize(category: "custom", message: nil, metadata: {})
        @active = true
        @timestamp = Time.now.utc

        @category = category
        @message = message
        @metadata = metadata.is_a?(Hash) ? metadata : {}
      end

      def to_h
        {
          category: category,
          message: message,
          metadata: metadata,
          timestamp: timestamp.iso8601(3)
        }
      end

      def <=>(other)
        to_h <=> other.to_h
      end


      # Is the Breadcrumb active or not. Inactive Breadcrumbs not be included
      # with any outgoing payloads.
      #
      # @return [Boolean]
      def active?
        @active
      end

      # Sets the breadcrumb to inactive
      #
      # @return self
      def ignore!
        @active = false
        self
      end
    end
  end
end

Version data entries

65 entries across 65 versions & 1 rubygems

Version Path
honeybadger-5.24.0 lib/honeybadger/breadcrumbs/breadcrumb.rb
honeybadger-5.23.0 lib/honeybadger/breadcrumbs/breadcrumb.rb
honeybadger-5.22.0 lib/honeybadger/breadcrumbs/breadcrumb.rb
honeybadger-5.21.0 lib/honeybadger/breadcrumbs/breadcrumb.rb
honeybadger-5.20.1 lib/honeybadger/breadcrumbs/breadcrumb.rb
honeybadger-5.20.0 lib/honeybadger/breadcrumbs/breadcrumb.rb
honeybadger-5.19.2 lib/honeybadger/breadcrumbs/breadcrumb.rb
honeybadger-5.19.1 lib/honeybadger/breadcrumbs/breadcrumb.rb
honeybadger-5.19.0 lib/honeybadger/breadcrumbs/breadcrumb.rb
honeybadger-5.18.0 lib/honeybadger/breadcrumbs/breadcrumb.rb
honeybadger-5.17.0 lib/honeybadger/breadcrumbs/breadcrumb.rb
honeybadger-5.16.0 lib/honeybadger/breadcrumbs/breadcrumb.rb
honeybadger-5.15.6 lib/honeybadger/breadcrumbs/breadcrumb.rb
honeybadger-5.15.5 lib/honeybadger/breadcrumbs/breadcrumb.rb
honeybadger-5.15.4 lib/honeybadger/breadcrumbs/breadcrumb.rb
honeybadger-5.15.3 lib/honeybadger/breadcrumbs/breadcrumb.rb
honeybadger-5.15.2 lib/honeybadger/breadcrumbs/breadcrumb.rb
honeybadger-5.15.1 lib/honeybadger/breadcrumbs/breadcrumb.rb
honeybadger-5.15.0 lib/honeybadger/breadcrumbs/breadcrumb.rb
honeybadger-5.14.2 lib/honeybadger/breadcrumbs/breadcrumb.rb