Class: LogStasher::Device::UDP

Inherits:
Object
  • Object
show all
Includes:
LogStasher::Device
Defined in:
lib/logstasher/device/udp.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from LogStasher::Device

factory, stringify_keys

Constructor Details

#initialize(options = {}) ⇒ UDP

Returns a new instance of UDP.



14
15
16
17
# File 'lib/logstasher/device/udp.rb', line 14

def initialize(options = {})
  @options = default_options.merge(stringify_keys(options))
  @socket = UDPSocket.new
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



12
13
14
# File 'lib/logstasher/device/udp.rb', line 12

def options
  @options
end

#socketObject (readonly)

Returns the value of attribute socket.



12
13
14
# File 'lib/logstasher/device/udp.rb', line 12

def socket
  @socket
end

Instance Method Details

#closeObject



19
20
21
# File 'lib/logstasher/device/udp.rb', line 19

def close
  @socket.close
end

#write(log) ⇒ Object



23
24
25
# File 'lib/logstasher/device/udp.rb', line 23

def write(log)
  @socket.send(log, 0, options['hostname'], options['port'])
end