<commit_before>require_relative 'breadcrumb'

module Raygun
  module Breadcrumbs
    class Store
      def self.initialize
        Thread.current[:breadcrumbs] ||= []
      end

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

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

      def self.record(crumb = nil, &block)
        crumb = Breadcrumb.new if crumb == nil

        block.call(crumb)

        crumb.method_name = caller_locations[1].label if crumb.method_name == nil
        crumb.timestamp = Time.now.utc if crumb.timestamp == nil
        crumb.level = :info if crumb.level == nil

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

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

      private

      def self.should_record?(crumb)
        levels = Raygun::Breadcrumbs::BREADCRUMB_LEVELS

        active_level = levels.index(Raygun.configuration.breadcrumb_level)
        crumb_level = levels.index(crumb.level) || -1

        crumb_level >= active_level<commit_msg>Automatically add line number of breadcrumb location<commit_after>require_relative 'breadcrumb'

module Raygun
  module Breadcrumbs
    class Store
      def self.initialize
        Thread.current[:breadcrumbs] ||= []
      end

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

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

      def self.record(crumb = nil, &block)
        crumb = Breadcrumb.new if crumb == nil

        block.call(crumb)

        caller = caller_locations[1]
        crumb.method_name = caller.label if crumb.method_name == nil
        crumb.line_number = caller.lineno
        crumb.timestamp = Time.now.utc if crumb.timestamp == nil
        crumb.level = :info if crumb.level == nil

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

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

      private

      def self.should_record?(crumb)
        levels = Raygun::Breadcrumbs::BREADCRUMB_LEVELS

        active_level = levels.index(Raygun.configuration.breadcrumb_level)
        crumb_level = levels.index(crumb.level) || -1

        crumb_level >= active_level
{'fraction_non_alphanumeric': 0.0917512130569034, 'fraction_numerical': 0.002646669607410675, 'mean_word_length': 2.3800298062593144, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4497193', 'n_tokens_mistral': 707, 'n_tokens_neox': 695, 'n_words': 149}