Log4r

P

Patrick Spence

The following code is throwing errors below. It looks like the wrong
module is getting referenced. The constructor for
c:\ruby\lib\ruby\1.8\Logger.rb takes 3-arguments. Seems to be some
confusion here. Can someone point me in the right direction?

Thanks!


require 'log4r'
include Log4r

#-- error getting thrown on this line
mylog = Logger.new('errorLogger.txt', nil, nil, true)

# Now we can log.
def do_log(log)
log.debug "This is a message with level DEBUG"
log.info "This is a message with level INFO"
log.warn "This is a message with level WARN"
log.error "This is a message with level ERROR"
log.fatal "This is a message with level FATAL"
end

do_log(mylog)

#--
#-- errors
#--
wrong number of arguments (4 for 3)
testLogger.rb:18:in `initialize'
testLogger.rb:18
testLogger.rb:18:in `initialize': wrong number of arguments (4 for 3)
(ArgumentError)
from testLogger.rb:18
 
P

Patrick Spence

Nicolai said:
Logger.new() takes only three (not 4) parameters.

See http://log4r.sourceforge.net/rdoc/classes/Log4r/Logger.html.

This is what threw me off...

def initialize(_fullname, _level=nil, _additive=true, _trace=false)
# validation
raise ArgumentError, "Logger must have a name", caller if
_fullname.nil?
Log4rTools.validate_level(_level) unless _level.nil?
validate_name(_fullname)

# create the logger
@fullname = _fullname
@outputters = []
@additive = _additive
deal_with_inheritance(_level)
LoggerFactory.define_methods(self)
self.trace = _trace
Repository[@fullname] = self
end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,060
Latest member
BuyKetozenseACV

Latest Threads

Top