Sha256: e6c78330ef0cfe770102ebc3b6ecf25338f52b1c975298cf97a8a5b7c699473c

Contents?: true

Size: 891 Bytes

Versions: 4

Compression:

Stored size: 891 Bytes

Contents

require 'logger'

module RackWebDAV
  # 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

4 entries across 4 versions & 1 rubygems

Version Path
rack-webdav-0.4.3 lib/rack-webdav/logger.rb
rack-webdav-0.4.2 lib/rack-webdav/logger.rb
rack-webdav-0.4.1 lib/rack-webdav/logger.rb
rack-webdav-0.4.0 lib/rack-webdav/logger.rb