Sha256: 7b70af11d9e312f5b90d10fe024b0e38ec2e21b9c26165c8770ccd3ac6678462

Contents?: true

Size: 1.02 KB

Versions: 10

Compression:

Stored size: 1.02 KB

Contents

require 'logger'
module Filbunke
  class FilbunkeLogger

    def initialize(log_file_name, local, level)
      @local = local
      @log = if @local or log_file_name.nil?
        Logger.new(STDOUT) 
      else 
        Logger.new(log_file_name)
      end

      @log.level = parse_level(level)
    end

    def puts(msg)
      info(msg)
    end
    
    def log(msg)
      @log.info msg
    end

    def info(msg)
      @log.info msg
    end

    def error(msg)
      @log.error msg
    end

    def warn(msg)
      @log.warn msg
    end

    def debug(msg)
      @log.debug msg
    end

    def fatal(msg)
      @log.error msg
    end

    def parse_level(constantOrString)
      case constantOrString
        when 'debug' then Logger::DEBUG
        when 'info' then Logger::INFO
        when 'warn' then Logger::WARN
        when 'error' then Logger::ERROR
        when 'fatal' then Logger::ERROR
        when 'unknown' then Logger::UNKNOWN
        when nil then Logger::INFO
        else 
          constantOrString
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
filbunke-1.13.5 lib/filbunke/logger.rb
filbunke-1.13.4 lib/filbunke/logger.rb
filbunke-1.13.3 lib/filbunke/logger.rb
filbunke-1.13.2 lib/filbunke/logger.rb
filbunke-1.13.1 lib/filbunke/logger.rb
filbunke-1.13.0 lib/filbunke/logger.rb
filbunke-1.12.0 lib/filbunke/logger.rb
filbunke-1.11.9 lib/filbunke/logger.rb
filbunke-1.11.8 lib/filbunke/logger.rb
filbunke-1.11.6 lib/filbunke/logger.rb