Class: WEBrick::BasicLog

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

new(log_file=nil, level=nil)

[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

<<(obj)

[Source]

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

close()

[Source]

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

debug(msg)

[Source]

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

debug?()

[Source]

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

error(msg)

[Source]

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

error?()

[Source]

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

fatal(msg)

[Source]

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

fatal?()

[Source]

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

info(msg)

[Source]

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

info?()

[Source]

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

log(level, data)

[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

warn(msg)

[Source]

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

warn?()

[Source]

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

[Validate]