class Fluent::PullForward::WEBrickLogger

Constants

DEBUG
ERROR
FATAL
INFO
WARN

Public Class Methods

new(logger) click to toggle source
# File lib/fluent/plugin/webrick_logger_bridge.rb, line 10
def initialize(logger)
  @logger = logger
end

Public Instance Methods

<<(str) click to toggle source
# File lib/fluent/plugin/webrick_logger_bridge.rb, line 14
def <<(str)
  self.log(INFO, str.to_s)
end
close() click to toggle source
# File lib/fluent/plugin/webrick_logger_bridge.rb, line 18
def close
  # NOP
end
debug(msg) click to toggle source
# File lib/fluent/plugin/webrick_logger_bridge.rb, line 22
def debug(msg)
  self.log(DEBUG, msg)
end
debug?() click to toggle source
# File lib/fluent/plugin/webrick_logger_bridge.rb, line 26
def debug?
  @logger.level > Fluent::Log::LEVEL_TRACE
end
error(msg) click to toggle source
# File lib/fluent/plugin/webrick_logger_bridge.rb, line 30
def error(msg)
  self.log(ERROR, msg)
end
error?() click to toggle source
# File lib/fluent/plugin/webrick_logger_bridge.rb, line 34
def error?
  @logger.level > Fluent::Log::LEVEL_WARN
end
fatal(msg) click to toggle source
# File lib/fluent/plugin/webrick_logger_bridge.rb, line 38
def fatal(msg)
  self.log(FATAL, msg)
end
fatal?() click to toggle source
# File lib/fluent/plugin/webrick_logger_bridge.rb, line 42
def fatal?
  @logger.level > Fluent::Log::LEVEL_ERROR
end
info(msg) click to toggle source
# File lib/fluent/plugin/webrick_logger_bridge.rb, line 46
def info(msg)
  self.log(INFO, msg)
end
info?() click to toggle source
# File lib/fluent/plugin/webrick_logger_bridge.rb, line 50
def info?
  @logger.level > Fluent::Log::LEVEL_DEBUG
end
level() click to toggle source
# File lib/fluent/plugin/webrick_logger_bridge.rb, line 54
def level
  # (Fluentd logger level num) -> (Webrick level num)
  # 5 -> 1
  # 4 -> 2
  # 3 -> 3
  # 2 -> 4
  # 1 -> 5
  # (6 - level)
  6 - @logger.level
end
level=(lv) click to toggle source
# File lib/fluent/plugin/webrick_logger_bridge.rb, line 65
def level=(lv)
  @logger.level = case lv
                  when FATAL then 'fatal'
                  when ERROR then 'error'
                  when WARN then 'warn'
                  when INFO then 'info'
                  when DEBUG then 'debug'
                  else
                    raise ArgumentError, "Invalid loglevel for webrick bridge logger: #{lv}"
                  end
end
log(level, msg) click to toggle source
# File lib/fluent/plugin/webrick_logger_bridge.rb, line 77
def log(level, msg)
  case level
  when FATAL
    @logger.fatal(msg)
  when ERROR
    @logger.error(msg)
  when WARN
    @logger.warn(msg)
  when INFO
    @logger.info(msg)
  when DEBUG
    @logger.debug(msg)
  else
    raise ArgumentError, "Invalid loglevel for webrick bridge logger: #{lv}"
  end
end
warn(msg) click to toggle source
# File lib/fluent/plugin/webrick_logger_bridge.rb, line 94
def warn(msg)
  self.log(WARN, msg)
end
warn?() click to toggle source
# File lib/fluent/plugin/webrick_logger_bridge.rb, line 98
def warn?
  @logger.level > Fluent::Log::LEVEL_INFO
end