Sha256: 2d01d53e6ceca7f8d9011834bab1d0fef9c13e5dd0a5196740d277c5cae3002c

Contents?: true

Size: 988 Bytes

Versions: 1

Compression:

Stored size: 988 Bytes

Contents

require 'logger'
module Waves

  module Logger

    # Returns the object being used for output by the logger.
    def self.output
      @output ||= ( config[:output] or $stderr )
    end
    
    # Returns the active configuration for the logger.
    def self.config ; @config ||= Waves.config.log ; end
    
    # Returns the logging level used to filter logging events.
    def self.level ; @level ||= ::Logger.const_get( config[:level].to_s.upcase || 'INFO' ) ; end
    
    # Starts the logger, using the active configuration to initialize it.
    def self.start
      @log = config[:rotation] ?
        ::Logger.new( output, config[:rotation].to_sym ) :
        ::Logger.new( output )
      @log.level = level
      @log.datetime_format = "%Y-%m-%d %H:%M:%S "
      self
    end
    
    # Forwards logging methods to the logger.
    def self.method_missing(name,*args,&block)
      cache_method_missing name, "@log.#{name} *args, &block if @log", *args, &block
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
waves-edge-2009.03.10.13.14 lib/runtime/logger.rb