lib/fluent/plugin/out_logentries.rb in fluent-plugin-logentries-0.2.2 vs lib/fluent/plugin/out_logentries.rb in fluent-plugin-logentries-0.2.3
- old
+ new
@@ -7,19 +7,22 @@
# First, register the plugin. NAME is the name of this plugin
# and identifies the plugin in the configuration file.
Fluent::Plugin.register_output('logentries', self)
config_param :use_ssl, :bool, :default => true
- config_param :no_ssl_port, :integer, :default => 80
+ config_param :port, :integer, :default => 20000
+ config_param :protocol, :string, :default => 'tcp'
config_param :config_path, :string
config_param :max_retries, :integer, :default => 3
config_param :tag_access_log, :string, :default => 'logs-access'
config_param :tag_error_log, :string, :default => 'logs-error'
+ SSL_HOST = "api.logentries.com"
+ NO_SSL_HOST = "data.logentries.com"
+
def configure(conf)
super
-
@tokens = nil
@last_edit = Time.at(0)
end
def start
@@ -28,18 +31,25 @@
def shutdown
super
end
- def client
+ def ssl_client
@_socket ||= if @use_ssl
context = OpenSSL::SSL::SSLContext.new
- socket = TCPSocket.new "api.logentries.com", 20000
+ socket = TCPSocket.new SSL_HOST, @port
ssl_client = OpenSSL::SSL::SSLSocket.new socket, context
ssl_client.connect
else
- TCPSocket.new "data.logentries.com", @no_ssl_port
+ if @protocol == 'tcp'
+ TCPSocket.new NO_SSL_HOST, @port
+ else
+ udp_client = UDPSocket.new
+ udp_client.connect NO_SSL_HOST, @port
+
+ udp_client
+ end
end
end
# This method is called when an event reaches Fluentd.
def format(tag, time, record)