![show/hide quicksearch [+]](../images/find.png)
 
               # File webrick/log.rb, line 18
def initialize(log_file=nil, level=nil)
  @level = level || INFO
  case log_file
  when String
    @log = open(log_file, "a+")
    @log.sync = true
    @opened = true
  when NilClass
    @log = $stderr
  else
    @log = log_file  # requires "<<". (see BasicLog#log)
  end
end
             
             
               # File webrick/log.rb, line 32
def close
  @log.close if @opened
  @log = nil
end
             
             
               # File webrick/log.rb, line 52
def debug(msg) log(DEBUG, "DEBUG " << format(msg)); end
             
             
               # File webrick/log.rb, line 49
def error(msg) log(ERROR, "ERROR " << format(msg)); end
             
             
               # File webrick/log.rb, line 48
def fatal(msg) log(FATAL, "FATAL " << format(msg)); end
             
             
               # File webrick/log.rb, line 51
def info(msg)  log(INFO,  "INFO  " << format(msg)); end
             
             
               # File webrick/log.rb, line 37
def log(level, data)
  if @log && level <= @level
    data += "\n" if /\n\Z/ !~ data
    @log << data
  end
end
             
            Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.
If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.