Sha256: b8cc05a5229b9543acdeb2f514e3d9f345c76a5227ce475ed3b90f698aa713f3

Contents?: true

Size: 577 Bytes

Versions: 1

Compression:

Stored size: 577 Bytes

Contents

# frozen_string_literal: true

require 'logger'

module Emittance
  class Middleware
    ##
    # Middleware for logging events
    #
    class Logging < Emittance::Middleware
      @current_logger = Logger.new(STDOUT)

      class << self
        attr_accessor :current_logger
      end

      def up
        current_logger.info event_log_str

        event
      end

      private

      def current_logger
        self.class.current_logger
      end

      def event_log_str
        "Emittance: #{event.identifiers.last.inspect} event emitted."
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
emittance-2.0.0.pre.1 lib/emittance/middleware/logging.rb