Class: Sysloggly::Clients::Networklog
- Inherits:
-
Object
- Object
- Sysloggly::Clients::Networklog
- Defined in:
- lib/sysloggly/clients/networklog.rb
Instance Attribute Summary collapse
-
#input_uri ⇒ Object
readonly
Returns the value of attribute input_uri.
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
Instance Method Summary collapse
-
#close ⇒ Object
Required by Logger::LogDevice.
-
#initialize(input_uri) ⇒ Sysloggly::Client::Networklog
constructor
Creates a new client that conforms to the Logger::LogDevice specification.
-
#write(message) ⇒ Object
Required by Logger::LogDevice.
Constructor Details
#initialize(input_uri) ⇒ Sysloggly::Client::Networklog
Creates a new client that conforms to the Logger::LogDevice specification.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/sysloggly/clients/networklog.rb', line 12 def initialize(input_uri) @input_uri = input_uri case @input_uri.scheme when "udp" @socket = UDPSocket.new @socket.connect(@input_uri.host, @input_uri.port) when "tcp" @socket = TCPSocket.new(@input_uri.host, @input_uri.port) @socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, 1) @socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, true) end end |
Instance Attribute Details
#input_uri ⇒ Object (readonly)
Returns the value of attribute input_uri.
6 7 8 |
# File 'lib/sysloggly/clients/networklog.rb', line 6 def input_uri @input_uri end |
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
6 7 8 |
# File 'lib/sysloggly/clients/networklog.rb', line 6 def socket @socket end |
Instance Method Details
#close ⇒ Object
Required by Logger::LogDevice
40 41 42 |
# File 'lib/sysloggly/clients/networklog.rb', line 40 def close @socket.close end |
#write(message) ⇒ Object
Required by Logger::LogDevice
29 30 31 32 33 34 35 |
# File 'lib/sysloggly/clients/networklog.rb', line 29 def write() begin @socket.send(, 0) rescue Timeout::Error => e STDOUT.puts "WARNING: Timeout::Error posting message: #{}" end end |