Class: Fluent::PullForward::WEBrickLogger
- Inherits:
-
Object
- Object
- Fluent::PullForward::WEBrickLogger
- Defined in:
- lib/fluent/plugin/webrick_logger_bridge.rb
Constant Summary collapse
- FATAL =
1- ERROR =
2- WARN =
3- INFO =
4- DEBUG =
5
Instance Method Summary collapse
- #<<(str) ⇒ Object
- #close ⇒ Object
- #debug(msg) ⇒ Object
- #debug? ⇒ Boolean
- #error(msg) ⇒ Object
- #error? ⇒ Boolean
- #fatal(msg) ⇒ Object
- #fatal? ⇒ Boolean
- #info(msg) ⇒ Object
- #info? ⇒ Boolean
-
#initialize(logger) ⇒ WEBrickLogger
constructor
A new instance of WEBrickLogger.
- #level ⇒ Object
- #level=(lv) ⇒ Object
- #log(level, msg) ⇒ Object
- #warn(msg) ⇒ Object
- #warn? ⇒ Boolean
Constructor Details
#initialize(logger) ⇒ WEBrickLogger
Returns a new instance of WEBrickLogger.
11 12 13 |
# File 'lib/fluent/plugin/webrick_logger_bridge.rb', line 11 def initialize(logger) @logger = logger end |
Instance Method Details
#<<(str) ⇒ Object
15 16 17 |
# File 'lib/fluent/plugin/webrick_logger_bridge.rb', line 15 def <<(str) self.log(INFO, str.to_s) end |
#close ⇒ Object
19 20 21 |
# File 'lib/fluent/plugin/webrick_logger_bridge.rb', line 19 def close # NOP end |
#debug(msg) ⇒ Object
23 24 25 |
# File 'lib/fluent/plugin/webrick_logger_bridge.rb', line 23 def debug(msg) self.log(DEBUG, msg) end |
#debug? ⇒ Boolean
27 28 29 |
# File 'lib/fluent/plugin/webrick_logger_bridge.rb', line 27 def debug? @logger.level > Fluent::Log::LEVEL_TRACE end |
#error(msg) ⇒ Object
31 32 33 |
# File 'lib/fluent/plugin/webrick_logger_bridge.rb', line 31 def error(msg) self.log(ERROR, msg) end |
#error? ⇒ Boolean
35 36 37 |
# File 'lib/fluent/plugin/webrick_logger_bridge.rb', line 35 def error? @logger.level > Fluent::Log::LEVEL_WARN end |
#fatal(msg) ⇒ Object
39 40 41 |
# File 'lib/fluent/plugin/webrick_logger_bridge.rb', line 39 def fatal(msg) self.log(FATAL, msg) end |
#fatal? ⇒ Boolean
43 44 45 |
# File 'lib/fluent/plugin/webrick_logger_bridge.rb', line 43 def fatal? @logger.level > Fluent::Log::LEVEL_ERROR end |
#info(msg) ⇒ Object
47 48 49 |
# File 'lib/fluent/plugin/webrick_logger_bridge.rb', line 47 def info(msg) self.log(INFO, msg) end |
#info? ⇒ Boolean
51 52 53 |
# File 'lib/fluent/plugin/webrick_logger_bridge.rb', line 51 def info? @logger.level > Fluent::Log::LEVEL_DEBUG end |
#level ⇒ Object
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/fluent/plugin/webrick_logger_bridge.rb', line 55 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) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/fluent/plugin/webrick_logger_bridge.rb', line 66 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) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/fluent/plugin/webrick_logger_bridge.rb', line 78 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) ⇒ Object
95 96 97 |
# File 'lib/fluent/plugin/webrick_logger_bridge.rb', line 95 def warn(msg) self.log(WARN, msg) end |
#warn? ⇒ Boolean
99 100 101 |
# File 'lib/fluent/plugin/webrick_logger_bridge.rb', line 99 def warn? @logger.level > Fluent::Log::LEVEL_INFO end |