Sha256: 63becdc02aefe4e26bd41a1ff06b8afd96f1f0f2f377442b08c4b18d26aa6b3c

Contents?: true

Size: 839 Bytes

Versions: 8

Compression:

Stored size: 839 Bytes

Contents

require 'logger'

module Gumdrop  
  
  module Util
    module Loggable
      def log
        Gumdrop.log
      end
    end
  end

  class << self

    LOG_LEVELS= {
        debug: Logger::DEBUG,
         info: Logger::INFO,
         warn: Logger::WARN,
        error: Logger::ERROR,
        fatal: Logger::FATAL,
      unknown: Logger::UNKNOWN
    }

    def log
      @log ||= begin
        log= Logger.new STDOUT
        log.level= LOG_LEVELS[:warn]
        log
      end
    end

    def init_logging
      level= (site.config.log_level || :warn).to_sym
      @log = Logger.new site.config.log || STDOUT
      @log.level=  LOG_LEVELS[level]
      # @log.formatter = proc { |severity, datetime, progname, msg|
      #   # original_formatter.call(severity, datetime, progname, msg.dump)
      #   "#{msg}\n"
      # }
    end

  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
gumdrop-1.1.3 lib/gumdrop/util/loggable.rb
gumdrop-1.1.2 lib/gumdrop/util/loggable.rb
gumdrop-1.1.1 lib/gumdrop/util/loggable.rb
gumdrop-1.1.0 lib/gumdrop/util/loggable.rb
gumdrop-1.0.3 lib/gumdrop/util/loggable.rb
gumdrop-1.0.2 lib/gumdrop/util/loggable.rb
gumdrop-1.0.1 lib/gumdrop/util/loggable.rb
gumdrop-1.0.0 lib/gumdrop/util/loggable.rb