Sha256: 6da98f3740d351e02962ba6fe47f6c5500f594cc15d2c0b37fb38def1395caa4

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

require "fluent/mixin/config_placeholders"

module Fluent
  class RemoteSyslogOutput < Fluent::Output
    Fluent::Plugin.register_output("remote_syslog", self)

    config_param :hostname, :string, :default => ""

    config_param :key_name, :string, :default => "message"

    config_param :host, :string
    config_param :port, :integer, :default => 25

    config_param :facility, :string, :default => "user"
    config_param :severity, :string, :default => "notice"
    config_param :tag, :string, :default => "fluentd"

    include Fluent::Mixin::ConfigPlaceholders

    def initialize
      super
      require "remote_syslog_logger"
    end

    def configure(conf)
      super
      @logger = RemoteSyslogLogger::UdpSender.new(@host,
                                                  @port,
                                                  facility: @facility,
                                                  severity: @severity,
                                                  program: @tag,
                                                  local_hostname: @hostname)
    end

    def shutdown
      super
      @logger.close if @logger
    end

    def emit(tag, es, chain)
      chain.next
      es.each do |time, record|
        @logger.transmit record[@key_name]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fluent-plugin-remote_syslog-0.1.0 lib/fluent/plugin/out_remote_syslog.rb