Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fluent::Logger::TextLogger and ConsoleLogger buggy? #66

Open
dCSeven opened this issue May 19, 2017 · 2 comments
Open

Fluent::Logger::TextLogger and ConsoleLogger buggy? #66

dCSeven opened this issue May 19, 2017 · 2 comments

Comments

@dCSeven
Copy link

dCSeven commented May 19, 2017

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:

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

irb(main):027:0> Fluent::Logger::FluentLogger.open nil, "localhost", 9400
=> #<Fluent::Logger::FluentLogger:0x2ddc8a8 @tag_prefix=nil, @host="localhost", @port=9400, @socket_path=nil, @nanosecond_precision=nil, @factory=#<MessagePack::Factory:0x2ddc7d0>, @packer=, @mon=#<Monitor:0x2ddc6e0 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Mutex:0x2ddc6b0>>, @pending=nil, @connect_error_history=[], @limit=8388608, @log_reconnect_error_threshold=13, @buffer_overflow_handler=nil, @logger=#<Logger:0x2ddc680 @progname=nil, @level=1, @default_formatter=#<Logger::Formatter:0x2ddc668 @datetime_format=nil>, @formatter=nil, @logdev=#<Logger::LogDevice:0x2ddc638 @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<IO:<STDERR>>, @mutex=#<Logger::LogDevice::LogDeviceMutex:0x2ddc620 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Mutex:0x2ddc5d8>>>>, @last_error={}, @con=#<TCPSocket:fd 3>, @logged_reconnect_error=false>
irb(main):028:0> Fluent::Logger.post "test",{level:"Debug",message:"Another try"}
=> true

This one doesn't work

irb(main):029:0> Fluent::Logger::ConsoleLogger.open STDOUT
=> #<Fluent::Logger::ConsoleLogger:0x2d89358 @time_format="%b %e %H:%M:%S", @io=#<IO:<STDOUT>>, @on_reopen=#<Proc:0x2d88d28@D:/Ruby193/lib/ruby/gems/1.9.1/gems/fluent-logger-0.7.1/lib/fluent/logger/console_logger.rb:32>>
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 `<main>'

The same thing happens with the TextLogger

Platform: Microsoft Windows 7

λ ruby -v
ruby 1.9.3p551 (2014-11-13) [i386-mingw32]

λ gem list --local
...
fluent-logger (0.7.1)
msgpack (1.1.0)
...
@repeatedly
Copy link
Member

It seems json gem version issue.
Latest json, tested with ruby 2.4's json gem, can dump non-object/array value.

We don't maintain these loggers and we have a plan to remove these loggers from fluent-logger.
So I recommend to not use these loggers.

@dCSeven
Copy link
Author

dCSeven commented May 19, 2017

My json version was 1.5.5
I upgraded it now (with all my other gems) to 2.1.0 (latest), but this didn't change anything

here is the full list of my installed gems (in case it would help you (in case you would maintain it ^^))

λ gem list

*** LOCAL GEMS ***

addressable (2.4.0)
amq-protocol (1.9.2)
amqp (1.5.3)
bigdecimal (1.1.0)
bson (4.2.1)
bson_ext (1.12.5)
bundler (1.14.6)
configuration (1.3.4)
cookiejar (0.3.3)
em-http-request (1.1.5)
em-mongo (0.5.1)
em-socksify (0.3.1)
eventmachine (1.2.3 x86-mingw32)
fluent-logger (0.7.1)
http_parser.rb (0.6.0)
io-console (0.3)
json (2.1.0)
minitest (5.10.2)
msgpack (1.1.0)
newrelic_rpm (3.18.1.330)
rake (12.0.0)
rdoc (3.9.5)

But if you plan to remove it I'll make something up myself.

Thanks anyway

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants