Class: Fluent::Logger::TextLogger

Inherits:
LoggerBase show all
Defined in:
lib/fluent/logger/text_logger.rb

Direct Known Subclasses

ConsoleLogger

Instance Method Summary collapse

Methods inherited from LoggerBase

#close, open, #post

Constructor Details

#initializeTextLogger

Returns a new instance of TextLogger.



21
22
23
24
# File 'lib/fluent/logger/text_logger.rb', line 21

def initialize
  require 'json'
  @time_format = "%b %e %H:%M:%S"
end

Instance Method Details

#post_with_time(tag, map, time) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/fluent/logger/text_logger.rb', line 26

def post_with_time(tag, map, time)
  a = [time.strftime(@time_format), " ", tag, ":"]
  map.each_pair { |k,v|
    a << " #{k}="
    a << JSON.dump(v)
  }
  post_text a.join
  true
end