Sha256: 725561cd6020a3fceb8c9f2f4841e39f720080bb2ea6fe3fcb30842317047f05

Contents?: true

Size: 730 Bytes

Versions: 2

Compression:

Stored size: 730 Bytes

Contents

require "logger"

$stdout.sync = true

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)
	      logger = ::Logger.new($stdout)
		  logger.level = ::Logger.const_get("#{SmartCloud.config.logger_level}".upcase)
	      logger.progname = classname
	      logger
	    end
	  end
	end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
smartcloud-0.8.0 lib/smart_cloud/logger.rb
smartcloud-0.7.0 lib/smart_cloud/logger.rb