Skip to content

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

@dCSeven

Description

@dCSeven

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)
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions