Sha256: 29ee7ac63745c55f9270bbd406b708d2abde5015ca231f83a540f3e29cefad8e

Contents?: true

Size: 572 Bytes

Versions: 2

Compression:

Stored size: 572 Bytes

Contents

require "logger"
require "time"

module MessageQueue
  module Logging
    class Formatter < Logger::Formatter
      def call(severity, time, program_name, message)
        "#{time.utc.iso8601} #{Process.pid} #{severity} -- #{message}\n"
      end
    end

    def self.setup_logger(target = $stdout)
      @logger = Logger.new(target)
      @logger.formatter = Formatter.new
      @logger
    end

    def self.logger
      @logger || setup_logger
    end

    def self.logger=(logger)
      @logger = logger
    end

    def logger
      Logging.logger
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
message_queue-0.1.1 lib/message_queue/logging.rb
message_queue-0.1.0 lib/message_queue/logging.rb