Sha256: 64d22cc44e4cfafc885e280629e839b1513a702b853e2212e646ee5d88b03009

Contents?: true

Size: 637 Bytes

Versions: 17

Compression:

Stored size: 637 Bytes

Contents

# frozen_string_literal: true

require 'active_support/log_subscriber'

module Cased
  module Instrumentation
    class LogSubscriber < ActiveSupport::LogSubscriber
      def self.events=(value)
        Thread.current['cased_events'] = value
      end

      def self.events
        Thread.current['cased_events'] ||= 0
      end

      def self.reset_events
        self.events = 0
      end

      def audit_event(event)
        self.class.events += 1

        event = JSON.generate(event.payload[:event])
        name = color('Cased', CYAN, true)
        debug "  #{name} #{event}"
      end

      attach_to :cased
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
cased-ruby-0.8.0 lib/cased/instrumentation/log_subscriber.rb
cased-ruby-0.7.1 lib/cased/instrumentation/log_subscriber.rb
cased-ruby-0.7.0 lib/cased/instrumentation/log_subscriber.rb
cased-ruby-0.6.1 lib/cased/instrumentation/log_subscriber.rb
cased-ruby-0.5.2 lib/cased/instrumentation/log_subscriber.rb
cased-ruby-0.5.1 lib/cased/instrumentation/log_subscriber.rb
cased-ruby-0.5.0 lib/cased/instrumentation/log_subscriber.rb
cased-ruby-0.4.8 lib/cased/instrumentation/log_subscriber.rb
cased-ruby-0.4.7 lib/cased/instrumentation/log_subscriber.rb
cased-ruby-0.4.6 lib/cased/instrumentation/log_subscriber.rb
cased-ruby-0.4.5 lib/cased/instrumentation/log_subscriber.rb
cased-ruby-0.4.4 lib/cased/instrumentation/log_subscriber.rb
cased-ruby-0.4.3 lib/cased/instrumentation/log_subscriber.rb
cased-ruby-0.4.2 lib/cased/instrumentation/log_subscriber.rb
cased-ruby-0.4.1 lib/cased/instrumentation/log_subscriber.rb
cased-ruby-0.4.0 lib/cased/instrumentation/log_subscriber.rb
cased-ruby-0.3.3 lib/cased/instrumentation/log_subscriber.rb