Class: Logging::Appenders::Rtail
- Inherits:
-
IO
- Object
- IO
- Logging::Appenders::Rtail
- Defined in:
- lib/logging/appenders/rtail.rb
Overview
This class provides an Appender that can write to a Rtail service over UDP.
Instance Attribute Summary collapse
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
- #host ⇒ Object
-
#initialize(name, opts = {}) ⇒ Rtail
constructor
Creates a new Rtail Appender that will use the given host and port as the Rtail server destination.
-
#reopen ⇒ Object
Reopen the connection to the underlying logging destination.
Constructor Details
#initialize(name, opts = {}) ⇒ Rtail
Creates a new Rtail Appender that will use the given host and port as the Rtail server destination.
20 21 22 23 24 25 26 27 28 |
# File 'lib/logging/appenders/rtail.rb', line 20 def initialize(name, opts = {}) @host = opts.fetch(:host, 'localhost') @port = opts.fetch(:port, 9999) fail ArgumentError, 'Empty host and port is not appropriate' unless host && !host.empty? && port # Because it's UDP, we want it flushed to the server, immediately: super(name, connect(@host, @port), opts.merge(auto_flushing: true)) end |
Instance Attribute Details
#port ⇒ Object (readonly)
Returns the value of attribute port.
34 35 36 |
# File 'lib/logging/appenders/rtail.rb', line 34 def port @port end |
Instance Method Details
#host ⇒ Object
30 31 32 |
# File 'lib/logging/appenders/rtail.rb', line 30 def host @host.dup end |
#reopen ⇒ Object
Reopen the connection to the underlying logging destination. If the connection is currently closed then it will be opened. If the connection is currently open then it will be closed and immediately opened.
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/logging/appenders/rtail.rb', line 39 def reopen @mutex.synchronize do if defined? @io && @io flush close rescue nil end @io = connect(@host, @port) end super self end |