Sha256: 10ee32fb2563772e3d914d0da34b08c4acdbfcdbce3c37fa51505fd297b76714

Contents?: true

Size: 896 Bytes

Versions: 3

Compression:

Stored size: 896 Bytes

Contents

require 'logging'
require 'slf4r/abstract_logger_facade'

module Slf4r
  class LoggerFacade < AbstractLoggerFacade
    
    attr_reader :logger
    
    def initialize(name)
      super
      log_name = nil
      name.to_s.split("::").each do |n|
        if log_name
          log_name += "::#{n}"
        else
          log_name = n
        end
        @logger = ::Logging::Logger.new(log_name)
      end
    end

    private

    def log(type, msg)
      @logger.add(type, msg)
    end

    public 

    def debug?
      @logger.level == 0
    end

    def _debug(msg)
      log(0, msg)
    end

    def info?
      @logger.level <= 1
    end

    def _info(msg)
      log(1, msg)
    end

    def warn?
      @logger.level <= 2
    end

    def _warn(msg)
      log(2, msg)
    end

    def error?
      @logger.level <= 3
    end

    def _error(msg)
      log(3, msg)
    end
    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
slf4r-0.1.0 lib/slf4r/logging_logger.rb
slf4r-0.1.1 lib/slf4r/logging_logger.rb
slf4r-0.2.0 lib/slf4r/logging_logger.rb