Commit 6bcebac
authored
level_fluent_logger: call super to improve compatibility with logger (#108)
Fix #100
```ruby
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "fluent-logger" #, path: "/home/watson/src/fluent-logger-ruby"
gem "logger", "= 1.6.0"
end
f = Fluent::Logger::LevelFluentLogger.new('fluent')
f.info("some application running.")
p f.level
```
The compatibility has lost since logger gem v1.6.0.
So, the above code causes following `NoMethodError` error.
```
$ ruby logger.rb
E, [2025-09-05T18:03:49.313233 #102418] ERROR -- : Failed to connect fluentd: Connection refused - connect(2) for "localhost" port 24224
E, [2025-09-05T18:03:49.313616 #102418] ERROR -- : Connection will be retried.
E, [2025-09-05T18:03:49.314104 #102418] ERROR -- : FluentLogger: Can't send logs to localhost:24224: Connection refused - connect(2) for "localhost" port 24224
/home/watson/.rbenv/versions/3.4.5/lib/ruby/gems/3.4.0/gems/logger-1.6.0/lib/logger.rb:384:in 'Logger#level': undefined method '[]' for nil (NoMethodError)
@level_override[Fiber.current] || @Level
^^^^^^^^^^^^^^^
from logger.rb:10:in '<main>'
```
We should call `super` in inherited class.
FYI:
This problem will be fixed with logger 1.7.0 with
ruby/logger@1efdf6b
Signed-off-by: Shizuo Fujita <[email protected]>1 parent 0d649a4 commit 6bcebac
1 file changed
+2
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
0 commit comments