Sha256: a3b59b305647f57de072a43e6823478f402d5bc6ed1824282859de978af0e200

Contents?: true

Size: 555 Bytes

Versions: 8

Compression:

Stored size: 555 Bytes

Contents

require 'logger'

module Logging
  def logger
    @logger ||= Logging.logger_for(self.class.name)
  end

  # Use a hash class-ivar to cache a unique Logger per class:
  @loggers = {}

  class << self
    def logger_for(classname)
      @loggers[classname] ||= configure_logger_for(classname)
    end

    def configure_logger_for(classname)
      logger = Logger.new(STDOUT)
      logger.progname = classname
      logger.formatter = proc { |severity, datetime, progname, msg|
        "[#{severity}] #{progname}: #{msg}\n"}
      logger
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
clenver-0.1.15 lib/clenver/logging.rb
clenver-0.1.14 lib/clenver/logging.rb
clenver-0.1.13 lib/clenver/logging.rb
clenver-0.1.12 lib/clenver/logging.rb
clenver-0.1.10 lib/clenver/logging.rb
clenver-0.1.9 lib/clenver/logging.rb
clenver-0.1.8 lib/clenver/logging.rb
clenver-0.1.7 lib/clenver/logging.rb