Class: Itamae::Handler::Fluentd

Inherits:
Base
  • Object
show all
Defined in:
lib/itamae/handler/fluentd.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#actions, #recipes, #resources

Instance Method Summary collapse

Constructor Details

#initializeFluentd

Returns a new instance of Fluentd.



6
7
8
9
# File 'lib/itamae/handler/fluentd.rb', line 6

def initialize(*)
  super
  load_fluent_logger
end

Instance Attribute Details

#fluent_loggerObject

for test



4
5
6
# File 'lib/itamae/handler/fluentd.rb', line 4

def fluent_logger
  @fluent_logger
end

Instance Method Details

#event(type, payload = {}) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/itamae/handler/fluentd.rb', line 11

def event(type, payload = {})
  super

  unless @fluent_logger.post(type, payload.merge(hostname: hostname))
    Itamae.logger.warn "Sending logs to Fluentd failed: #{@fluent_logger.last_error}"
  end
end