new(log_file=nil, level=nil)
public
Initializes a new logger for
log_file that outputs messages at level or higher.
log_file can be a filename, an IO-like
object that responds to #<< or
nil which outputs to $stderr.
If no level is given INFO is chosen by default
Show source
def initialize(log_file=nil, level=nil)
@level = level || INFO
case log_file
when String
@log = File.open(log_file, "a+")
@log.sync = true
@opened = true
when NilClass
@log = $stderr
else
@log = log_file
end
end