Sha256: ffd048af0da413e387d9dd013ca4c5639d43286268f4bfb2f1732dea08c9d4cd

Contents?: true

Size: 663 Bytes

Versions: 2

Compression:

Stored size: 663 Bytes

Contents

require 'alephant/logger/version'
require 'logger'

module Alephant
  class DelegatingLogger
    attr_reader :logger

    def initialize(logger)
      @logger = logger
    end

    def method_missing(name, *args)
      logger.send(name, *args) if logger.respond_to? name
    end

    def respond_to?(name)
      logger.respond_to? name || super
    end
  end

  module Logger
    @@logger = nil

    def logger
      ::Alephant::Logger.get_logger
    end

    def self.get_logger
      @@logger ||= Alephant::DelegatingLogger.new ::Logger.new(STDOUT)
    end

    def self.set_logger(value)
      @@logger = Alephant::DelegatingLogger.new value
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alephant-logger-0.2.0 lib/alephant/logger.rb
alephant-logger-0.1.0 lib/alephant/logger.rb