Class: LogStashLogger::Device::TCP

Inherits:
Socket show all
Defined in:
lib/logstash-logger/device/tcp.rb

Constant Summary

Constants inherited from Socket

Socket::DEFAULT_HOST

Instance Attribute Summary collapse

Attributes inherited from Socket

#host, #port

Attributes inherited from Base

#io, #sync

Instance Method Summary collapse

Methods inherited from Connectable

#close, #connected?, #flush, #reconnect, #to_io, #with_connection, #write, #write_batch

Methods inherited from Base

#close, #flush, #to_io, #write

Constructor Details

#initialize(opts) ⇒ TCP

Returns a new instance of TCP.



8
9
10
11
12
13
# File 'lib/logstash-logger/device/tcp.rb', line 8

def initialize(opts)
  super

  @ssl_certificate = opts[:ssl_certificate]
  @use_ssl = !!(@ssl_certificate || opts[:use_ssl] || opts[:ssl_enable])
end

Instance Attribute Details

#ssl_certificateObject (readonly)

Returns the value of attribute ssl_certificate.



6
7
8
# File 'lib/logstash-logger/device/tcp.rb', line 6

def ssl_certificate
  @ssl_certificate
end

Instance Method Details

#connectObject



19
20
21
22
23
24
25
26
27
# File 'lib/logstash-logger/device/tcp.rb', line 19

def connect
  if use_ssl?
    ssl_connect
  else
    non_ssl_connect
  end

  @io
end

#use_ssl?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/logstash-logger/device/tcp.rb', line 15

def use_ssl?
  @use_ssl || !@ssl_certificate.nil?
end