Sha256: 5aea0e187d3c47a8c043e89b95c81b0076b9f67753cd749445b9a2d307442793

Contents?: true

Size: 1.22 KB

Versions: 28

Compression:

Stored size: 1.22 KB

Contents

=begin rdoc
  Logger
=end
module PoolParty  
  class PoolPartyLog

    @logger = nil
    
    class << self
      attr_accessor :logger, :level, :file #:nodoc
      
      def init(path = false)
        @file = path ? File.join(path, "poolparty.log") : StringIO.new
        @logger = Logger.new(file)
        level = @log_level = :info
      end
      
      # Sets the level for the Logger by symbol or by command line argument.
      # Throws an ArgumentError if you feed it a bogus log level (that is not
      # one of :debug, :info, :warn, :error, :fatal or the corresponding strings)
      def level=(loglevel)
        case loglevel.to_sym
        when :debug
          @logger.level = Logger::DEBUG
        when :info
          @logger.level = Logger::INFO
        when :warn
          @logger.level = Logger::WARN
        when :error
          @logger.level = Logger::ERROR
        when :fatal
          @logger.level = Logger::FATAL
        else
          raise ArgumentError, "Log level must be one of :debug, :info, :warn, :error, or :fatal"
        end
      end
      
      def method_missing(method_symbol, *args)
        init unless @logger
        @logger.send(method_symbol, *args)
      end
      
    end # class << self


  end
end

Version data entries

28 entries across 28 versions & 3 rubygems

Version Path
auser-poolparty-1.3.0 lib/poolparty/pool_party_log.rb
auser-poolparty-1.3.1 lib/poolparty/pool_party_log.rb
auser-poolparty-1.3.10 lib/poolparty/pool_party_log.rb
auser-poolparty-1.3.11 lib/poolparty/pool_party_log.rb
auser-poolparty-1.3.12 lib/poolparty/pool_party_log.rb
auser-poolparty-1.3.13 lib/poolparty/pool_party_log.rb
auser-poolparty-1.3.14 lib/poolparty/pool_party_log.rb
auser-poolparty-1.3.15 lib/poolparty/pool_party_log.rb
auser-poolparty-1.3.16 lib/poolparty/pool_party_log.rb
auser-poolparty-1.3.17 lib/poolparty/pool_party_log.rb
auser-poolparty-1.3.2 lib/poolparty/pool_party_log.rb
auser-poolparty-1.3.3 lib/poolparty/pool_party_log.rb
auser-poolparty-1.3.4 lib/poolparty/pool_party_log.rb
auser-poolparty-1.3.5 lib/poolparty/pool_party_log.rb
auser-poolparty-1.3.6 lib/poolparty/pool_party_log.rb
auser-poolparty-1.3.7 lib/poolparty/pool_party_log.rb
auser-poolparty-1.3.8 lib/poolparty/pool_party_log.rb
fairchild-poolparty-1.3.17 lib/poolparty/pool_party_log.rb
fairchild-poolparty-1.3.5 lib/poolparty/pool_party_log.rb
poolparty-1.3.15 lib/poolparty/pool_party_log.rb