Class: DAV4Rack::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/dav4rack/logger.rb

Overview

This is a simple wrapper for the Logger class. It allows easy access to log messages from the library.

Class Method Summary collapse

Class Method Details

.method_missing(*args) ⇒ Object



23
24
25
26
27
# File 'lib/dav4rack/logger.rb', line 23

def method_missing(*args)
  if(defined? @@logger)
    @@logger.send *args
  end
end

.set(*args) ⇒ Object

args

Arguments for Logger -> [path, level] (level is optional) or a Logger instance

Set the path to the log file.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/dav4rack/logger.rb', line 10

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