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
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#omit_timezone ⇒ Object
readonly
Returns the value of attribute omit_timezone.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#split_newline ⇒ Object
readonly
Returns the value of attribute split_newline.
Instance Method Summary collapse
-
#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.
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/logging/appenders/rtail.rb', line 25 def initialize(name, opts = {}) @host = opts.fetch(:host, 'localhost') @port = opts.fetch(:port, 9999) # FIXME: Rtail Server needs to be fixed to allow log-time output in localtime, instead of UTC. # For now, users may need to do this: @omit_timezone = opts.fetch(:omit_timezone, false) @split_newline = opts.fetch(:split_newline, true) 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
#host ⇒ Object (readonly)
Returns the value of attribute host.
14 15 16 |
# File 'lib/logging/appenders/rtail.rb', line 14 def host @host end |
#omit_timezone ⇒ Object (readonly)
Returns the value of attribute omit_timezone.
14 15 16 |
# File 'lib/logging/appenders/rtail.rb', line 14 def omit_timezone @omit_timezone end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
14 15 16 |
# File 'lib/logging/appenders/rtail.rb', line 14 def port @port end |
#split_newline ⇒ Object (readonly)
Returns the value of attribute split_newline.
14 15 16 |
# File 'lib/logging/appenders/rtail.rb', line 14 def split_newline @split_newline end |
Instance Method Details
#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.
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/logging/appenders/rtail.rb', line 42 def reopen @mutex.synchronize do if defined? @io && @io flush close rescue nil end @io = connect(@host, @port) end super self end |