Sha256: 6ef77fe01794ac076eea240b7acab684c285260a1bf0e009d4fc2d4ee151434a

Contents?: true

Size: 723 Bytes

Versions: 1

Compression:

Stored size: 723 Bytes

Contents

require "logger"

module Smartcloud
	module Logger
	  def logger
	    @logger ||= Smartcloud::Logger.logger_for(self.class.name)
	  end

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

	  def self.included(base)
		class << base
			def logger
			  @logger ||= Smartcloud::Logger.logger_for(self.name)
			end
		end
	  end

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

	    def configure_logger_for(classname)
		  $stdout.sync = true
	      logger = ::Logger.new($stdout)
		  logger.level = "::Logger::#{Smartcloud.config.logger_level}".to_sym
	      logger.progname = classname
	      logger
	    end
	  end
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
smartcloud-0.0.167 lib/smartcloud/logger.rb