fluent / fluent/fluent-logger-ruby
Fluent::Logger::TextLogger and ConsoleLogger buggy?
- Dominant language
- Ruby
- Stars
- 256
- Forks
- 77
- PR merge metrics
- No merged PRs in 30d
Description
I'm not sure if this is my fault, but when switching from FluentLogger to ConsoleLogger or TextLogger I get a JSON::GenerateError. But since there is no extended documentation on how to use the ConsoleLogger or TextLogger, I expected that they work the same way as the "core" FluentLogger. As this would allow for something handy like this:
```ruby
case environment
when 'production'
Fluent::Logger::FluentLogger.open nil, host:Fluent_host, port:Fluent_port
when 'local'
Fluent::Logger::ConsoleLogger.open STDOUT
end
```
While this works
```ruby
irb(main):027:0> Fluent::Logger::FluentLogger.open nil, "localhost", 9400
=> #, @packer=, @mon=#>, @pending=nil, @connect_error_history=[], @limit=8388608, @log_reconnect_error_threshold=13, @buffer_overflow_handler=nil, @logger=#, @formatter=nil, @logdev=#>, @mutex=#>>>, @last_error={}, @con=#, @logged_reconnect_error=false>
irb(main):028:0> Fluent::Logger.post "test",{level:"Debug",message:"Another try"}
=> true
```
This one doesn't work
```ruby
irb(main):029:0> Fluent::Logger::ConsoleLogger.open STDOUT
=> #>, @on_reopen=#>
irb(main):030:0> Fluent::Logger.post "test",{level:"Debug",message:"Another try"}
JSON::GeneratorError: only generation of JSON objects or arrays allowed
from D:/Ruby193/lib/ruby/1.9.1/json/common.rb:216:in `generate'
from D:/Ruby193/lib/ruby/1.9.1/json/common.rb:216:in `generate'
from D:/Ruby193/lib/ruby/1.9.1/json/common.rb:352:in `dump'
from D:/Ruby193/lib/ruby/gems/1.9.1/gems/fluent-logger-0.7.1/lib/fluent/logger/text_logger.rb:30:in `block in post_with_time'
from D:/Ruby193/lib/ruby/gems/1.9.1/gems/fluent-logger-0.7.1/lib/fluent/logger/text_logger.rb:28:in `each_pair'
from D:/Ruby193/lib/ruby/gems/1.9.1/gems/fluent-logger-0.7.1/lib/fluent/logger/text_logger.rb:28:in `post_with_time'
from D:/Ruby193/lib/ruby/gems/1.9.1/gems/fluent-logger-0.7.1/lib/fluent/logger/logger_base.rb:27:in `post'
from D:/Ruby193/lib/ruby/gems/1.9.1/gems/fluent-logger-0.7.1/lib/fluent/logger.rb:53:in `post'
from (irb):31
from D:/Ruby193/bin/irb:12:in `'
```
The same thing happens with the TextLogger
Platform: Microsoft Windows 7
```cmd
λ ruby -v
ruby 1.9.3p551 (2014-11-13) [i386-mingw32]
λ gem list --local
...
fluent-logger (0.7.1)
msgpack (1.1.0)
...
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the failure with the ConsoleLogger and TextLogger examples, then inspect lib/fluent/logger/text_logger.rb, lib/fluent/logger/logger_base.rb, and lib/fluent/logger.rb from the reported stack trace. Compare their post handling with FluentLogger and determine the expected shared interface; done means the reproduced payload no longer raises JSON::GenerateError or the usage difference is clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100