Sha256: 8caf26ba4070163d0ff55618b0383c2a9228ebf797630fd86fdbf64bd26fd2d9

Contents?: true

Size: 786 Bytes

Versions: 4

Compression:

Stored size: 786 Bytes

Contents

# frozen_string_literal: true

module Trifle
  module Logger
    class Configuration
      attr_accessor :tracer_class, :callbacks, :bump_every

      def initialize
        @tracer_class = Trifle::Logger::Tracer::Hash
        @callbacks = { liftoff: [], bump: [], wrapup: [] }
        @bump_every = 15.seconds
      end

      def on_liftoff(tracer)
        @callbacks.fetch(:liftoff, []).map do |c|
          c.call(tracer)
        end
      end

      def on_bump(tracer)
        @callbacks.fetch(:bump, []).map do |c|
          c.call(tracer)
        end
      end

      def on_wrapup(tracer)
        @callbacks.fetch(:wrapup, []).map do |c|
          c.call(tracer)
        end
      end

      def on(event, &block)
        @callbacks[event] << block
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
trifle-logger-0.4.1 lib/trifle/logger/configuration.rb
trifle-logger-0.4.0 lib/trifle/logger/configuration.rb
trifle-logger-0.3.1 lib/trifle/logger/configuration.rb
trifle-logger-0.3.0 lib/trifle/logger/configuration.rb