Class: Log4r::FluentOutputter
- Inherits:
-
Outputter
- Object
- Outputter
- Log4r::FluentOutputter
- Defined in:
- lib/log4r/fluent_outputter.rb
Constant Summary collapse
- VERSION =
"0.0.3"
Instance Attribute Summary collapse
-
#log ⇒ Object
Returns the value of attribute log.
-
#tag ⇒ Object
Returns the value of attribute tag.
Instance Method Summary collapse
- #canonical_log(logevent) ⇒ Object
-
#initialize(_name, hash = {}) ⇒ FluentOutputter
constructor
A new instance of FluentOutputter.
Constructor Details
#initialize(_name, hash = {}) ⇒ FluentOutputter
Returns a new instance of FluentOutputter.
11 12 13 14 15 16 17 |
# File 'lib/log4r/fluent_outputter.rb', line 11 def initialize(_name, hash={}) super(_name, hash) @tag = hash[:tag] || hash["tag"] || 'test' host = hash[:host] || hash["host"] || 'localhost' port = hash[:port] || hash["port"] || 24224 @log = Fluent::Logger::FluentLogger.new(nil, host: host, port: port.to_i) end |
Instance Attribute Details
#log ⇒ Object
Returns the value of attribute log.
9 10 11 |
# File 'lib/log4r/fluent_outputter.rb', line 9 def log @log end |
#tag ⇒ Object
Returns the value of attribute tag.
8 9 10 |
# File 'lib/log4r/fluent_outputter.rb', line 8 def tag @tag end |
Instance Method Details
#canonical_log(logevent) ⇒ Object
19 20 21 |
# File 'lib/log4r/fluent_outputter.rb', line 19 def canonical_log(logevent) @log.post(@tag, {l: logevent.level, d: logevent.data}) end |