Class WEBrick::BasicLog
In: webrick/log.rb
Parent: Object

Methods

<<   close   debug   debug?   error   error?   fatal   fatal?   info   info?   log   new   warn   warn?  

Constants

DEBUG = 1, 2, 3, 4, 5

Attributes

level  [RW] 

Public Class methods

[Source]

# 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

Public Instance methods

[Source]

# File webrick/log.rb, line 44
    def <<(obj)
      log(INFO, obj.to_s)
    end

[Source]

# File webrick/log.rb, line 32
    def close
      @log.close if @opened
      @log = nil
    end

[Source]

# File webrick/log.rb, line 52
    def debug(msg) log(DEBUG, "DEBUG " << format(msg)); end

[Source]

# File webrick/log.rb, line 58
    def debug?; @level >= DEBUG; end

[Source]

# File webrick/log.rb, line 49
    def error(msg) log(ERROR, "ERROR " << format(msg)); end

[Source]

# File webrick/log.rb, line 55
    def error?; @level >= ERROR; end

[Source]

# File webrick/log.rb, line 48
    def fatal(msg) log(FATAL, "FATAL " << format(msg)); end

[Source]

# File webrick/log.rb, line 54
    def fatal?; @level >= FATAL; end

[Source]

# File webrick/log.rb, line 51
    def info(msg)  log(INFO,  "INFO  " << format(msg)); end

[Source]

# File webrick/log.rb, line 57
    def info?;  @level >= INFO; end

[Source]

# File webrick/log.rb, line 37
    def log(level, data)
      if @log && level <= @level
        data += "\n" if /\n\Z/ !~ data
        @log << data
      end
    end

[Source]

# File webrick/log.rb, line 50
    def warn(msg)  log(WARN,  "WARN  " << format(msg)); end

[Source]

# File webrick/log.rb, line 56
    def warn?;  @level >= WARN; end

[Validate]

ruby-doc.org is hosted and maintained by James Britt and Happy Camper Studios, a Ruby application development company in Phoenix, Arizona. The site was created in 2002 as part of the Ruby Documentation Project to promote the Ruby language and to help other Ruby hackers.

Documentation content on ruby-doc.org is provided by remarkable members of the Ruby community.

For more information on the Ruby programming language, visit ruby-lang.org.

Want to help improve Ruby's API docs? See Ruby Documentation Guidelines.