Class: Fluent::Plugin::OutSyslogRFC5424

Inherits:
Output
  • Object
show all
Defined in:
lib/fluent/plugin/out_syslog_rfc5424.rb

Constant Summary collapse

DEFAULT_FORMATTER =
"syslog_rfc5424"

Instance Method Summary collapse

Instance Method Details

#closeObject



41
42
43
44
45
# File 'lib/fluent/plugin/out_syslog_rfc5424.rb', line 41

def close
  super
  @sockets.each_value { |s| s.close }
  @sockets = {}
end

#configure(config) ⇒ Object



20
21
22
23
24
# File 'lib/fluent/plugin/out_syslog_rfc5424.rb', line 20

def configure(config)
  super
  @sockets = {}
  @formatter = formatter_create
end

#write(chunk) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fluent/plugin/out_syslog_rfc5424.rb', line 26

def write(chunk)
  socket = find_or_create_socket(@transport.to_sym, @host, @port)
  tag = chunk..tag
  chunk.each do |time, record|
    begin
      socket.write_nonblock @formatter.format(tag, time, record)
      IO.select(nil, [socket], nil, 1) || raise(StandardError.new "ReconnectError")
    rescue => e
      @sockets.delete(socket_key(@transport.to_sym, @host, @port))
      socket.close
      raise
    end
  end
end