Sha256: 682294bcf17d501ee438f215323870775590bac2b9b01b9f108ec72f108ddbb6

Contents?: true

Size: 672 Bytes

Versions: 10

Compression:

Stored size: 672 Bytes

Contents

module Stackster
  class StacksterLogger

    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

10 entries across 10 versions & 1 rubygems

Version Path
stackster-0.4.4 lib/stackster/logger.rb
stackster-0.4.3 lib/stackster/logger.rb
stackster-0.4.2 lib/stackster/logger.rb
stackster-0.4.1 lib/stackster/logger.rb
stackster-0.4.0 lib/stackster/logger.rb
stackster-0.3.2 lib/stackster/logger.rb
stackster-0.3.1 lib/stackster/logger.rb
stackster-0.3.0 lib/stackster/logger.rb
stackster-0.2.9 lib/stackster/logger.rb
stackster-0.2.8 lib/stackster/logger.rb