Class: Log4r::UDPOutputter
- Defined in:
- lib/log4r/outputter/udpoutputter.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#udpsock ⇒ Object
Returns the value of attribute udpsock.
Attributes inherited from Outputter
Instance Method Summary collapse
-
#initialize(_name, hash = {}) ⇒ UDPOutputter
constructor
A new instance of UDPOutputter.
Methods inherited from Outputter
[], []=, each, each_outputter, #flush, #only_at, stderr, stdout
Constructor Details
#initialize(_name, hash = {}) ⇒ UDPOutputter
Returns a new instance of UDPOutputter.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/log4r/outputter/udpoutputter.rb', line 18 def initialize(_name, hash={}) super(_name, hash) @host = hash[:hostname] @port = hash[:port] begin Logger.log_internal { "UDPOutputter will send to #{@host}:#{@port}" } @udpsock = UDPSocket.new @udpsock.connect( @host, @port ) rescue Exception => e Logger.log_internal(ERROR) { "UDPOutputter failed to create UDP socket: #{e}" } Logger.log_internal {e} self.level = OFF raise e end end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
15 16 17 |
# File 'lib/log4r/outputter/udpoutputter.rb', line 15 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
15 16 17 |
# File 'lib/log4r/outputter/udpoutputter.rb', line 15 def port @port end |
#udpsock ⇒ Object
Returns the value of attribute udpsock.
16 17 18 |
# File 'lib/log4r/outputter/udpoutputter.rb', line 16 def udpsock @udpsock end |