Sha256: 1c271b8b05022774da90350d192a9b0010689965144be186a92befc50c5ee16c

Contents?: true

Size: 889 Bytes

Versions: 5

Compression:

Stored size: 889 Bytes

Contents

require 'logger'

module DAV4Rack
  # This is a simple wrapper for the Logger class. It allows easy access 
  # to log messages from the library.
  class Logger
    class << self
      # args:: Arguments for Logger -> [path, level] (level is optional) or a Logger instance
      # Set the path to the log file.
      def set(*args)
        if(%w(info debug warn fatal).all?{|meth| args.first.respond_to?(meth)})
          @@logger = args.first
        elsif(args.first.respond_to?(:to_s) && !args.first.to_s.empty?)
          @@logger = ::Logger.new(args.first.to_s, 'weekly')
        elsif(args.first)
          raise 'Invalid type specified for logger'
        end
        if(args.size > 1)
          @@logger.level = args[1]
        end
      end
      
      def method_missing(*args)
        if(defined? @@logger)
          @@logger.send *args
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dav4rack-0.3.0 lib/dav4rack/logger.rb
dav4rack-0.2.11 lib/dav4rack/logger.rb
dav4rack-0.2.10 lib/dav4rack/logger.rb
dav4rack-0.2.9 lib/dav4rack/logger.rb
dav4rack-0.2.8 lib/dav4rack/logger.rb