Sha256: 05b9f012f5ce61d160aed031ed8c97b529b0e00da7ac28bf5be742c5c3f70a4d

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

module Slf4r
  class AbstractLoggerFacade

    protected

    def format(exception)
      ": #{exception.message}:\n\t#{exception.backtrace.join("\n\t")}" if exception
    end
    
    def _debug(msg)
      raise NotImplementedError
    end

    def _info(msg)
      raise NotImplementedError
    end

    def _warn(msg)
      raise NotImplementedError
    end

    def _error(msg)
      raise NotImplementedError
    end

    public 

    attr_reader :name

    def initialize(name)
      @name = name
    end

    def debug?
      raise NotImplementedError
    end

    def debug(msg = nil, exception = nil)
      msg, exception = yield if block_given?
      _debug("#{msg}#{format(exception)}")
    end

    def info?
      raise NotImplementedError
    end

    def info(msg = nil, exception = nil)
      msg, exception = yield if block_given?
      _info("#{msg}#{format(exception)}")
    end

    def warn?
      raise NotImplementedError
    end

    def warn(msg = nil, exception = nil)
      msg, exception = yield if block_given?
      _warn("#{msg}#{format(exception)}")
    end

    def error?
      raise NotImplementedError
    end

    def error(msg = nil, exception = nil)
      msg, exception = yield if block_given?
      _error("#{msg}#{format(exception)}")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
slf4r-0.1.1 lib/slf4r/abstract_logger_facade.rb