Sha256: a11f8e21e08c3ccbb53ff32b4412d82c058706973854103658d75a8ea8ff1b5d

Contents?: true

Size: 674 Bytes

Versions: 25

Compression:

Stored size: 674 Bytes

Contents

module Heirloom
  class HeirloomLogger
    
    require 'forwardable'

    extend Forwardable

    def_delegators :@logger, :debug, :error, :info, :warn

    def initialize(args = {})
      @log_level = args[:log_level] ||= 'info'
      @logger    = args[:logger] ||= new_logger(args)
    end

    private

    def new_logger(args)
      Logger.new(STDOUT).tap do |l|
        l.datetime_format = '%Y-%m-%dT%H:%M:%S%z'
        l.formatter = proc do |severity, datetime, progname, msg|
          "#{datetime} #{severity} : #{msg}\n"
        end
        l.level = logger_level
      end
    end

    def logger_level
      Logger.const_get @log_level.upcase
    end

  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
heirloom-0.8.3 lib/heirloom/logger.rb
heirloom-0.8.2 lib/heirloom/logger.rb
heirloom-0.8.1 lib/heirloom/logger.rb
heirloom-0.8.0 lib/heirloom/logger.rb
heirloom-0.7.4 lib/heirloom/logger.rb
heirloom-0.7.3 lib/heirloom/logger.rb
heirloom-0.7.3rc2 lib/heirloom/logger.rb
heirloom-0.7.3rc1 lib/heirloom/logger.rb
heirloom-0.7.2 lib/heirloom/logger.rb
heirloom-0.7.2rc2 lib/heirloom/logger.rb
heirloom-0.7.2rc1 lib/heirloom/logger.rb
heirloom-0.7.1 lib/heirloom/logger.rb
heirloom-0.7.0 lib/heirloom/logger.rb
heirloom-0.7.0rc1 lib/heirloom/logger.rb
heirloom-0.6.1 lib/heirloom/logger.rb
heirloom-0.6.0rc1 lib/heirloom/logger.rb
heirloom-0.5.0rc4 lib/heirloom/logger.rb
heirloom-0.5.0rc3 lib/heirloom/logger.rb
heirloom-0.5.0rc2 lib/heirloom/logger.rb
heirloom-0.5.0rc1 lib/heirloom/logger.rb