class SemanticLogger::Appender::Tcp


)
ssl: true
server: ‘server:3300’,
appender: :tcp,
SemanticLogger.add_appender(
Example, with SSL enabled:
)
connect_retry_count: 5
connect_retry_interval: 0.1,
server: ‘server:3300’,
appender: :tcp,
SemanticLogger.add_appender(
Example, with connection retry options:
)
server: ‘server:3300’,
appender: :tcp,
SemanticLogger.add_appender(
Example:
* Transparently reconnect when a connection is lost.
* SSL encryption.
* JSON Formatted messages.
Features:
By default messages are in JSON format.
Log to a server over a TCP Socket.
TCP log appender.

def close

Close is called during shutdown, or with reopen
def close
  @tcp_client&.close
end

def default_formatter

Returns [SemanticLogger::Formatters::Default] formatter default for this Appender
def default_formatter
  SemanticLogger::Formatters::Json.new
end

def flush

Flush is called by the semantic_logger during shutdown.
def flush
  @tcp_client&.flush
end

def initialize(separator: "\n",

)
connect_retry_count: 5
connect_retry_interval: 0.1,
server: 'server:3300',
appender: :tcp,
SemanticLogger.add_appender(
Example, with connection retry options:

)
server: 'server:3300'
appender: :tcp,
SemanticLogger.add_appender(
Example:
The Proc must return true or false.
Proc: Only include log messages where the supplied Proc returns true
regular expression. All other messages will be ignored.
RegExp: Only include log messages where the class name matches the supplied.
filter: [Regexp|Proc]

Default: Use the built-in formatter (See: #call)
the output from this appender
An instance of a class that implements #call, or a Proc to be used to format
formatter: [Object|Proc]

Default: SemanticLogger.default_level
Override the log level for this appender.
level: [:trace | :debug | :info | :warn | :error | :fatal]

Default: SemanticLogger.host
Name of this host to appear in log messages.
host: [String]

Default: SemanticLogger.application
Name of this application to appear in log messages.
application: [String]
Common Appender Parameters:

Note: The separator should not be something that could be output in the formatted log message.
Default: "\n"
Separator between every message
separator: [String]
Appender Parameters:

Default: true
This includes a Read Timeout
automatically close the connection if an error occurs
To prevent the connection from going into an inconsistent state
:close_on_error [True|False]

Default: :ordered
end
servers.last
:policy => Proc.new do |servers|
Example:
of servers. The Proc must return one server name
When a Proc is supplied, it will be called passing in the list
Proc:
The server with the lowest ping time will be tried first
FUTURE - Not implemented yet - Pull request anyone?
:ping_time
is established, including during automatic connection recovery.
Randomly select a server from the list every time a connection
:random
to if the first server is unreachable
having the highest priority. The second server will only be connected
Select a server in the order supplied in the array, with the first
:ordered
Specify the policy to use when connecting to servers.
:policy [Symbol|Proc]

- Perform a handshake with the server
- Pass any authentication information to the server
- Initialize per connection session sequence numbers
Typical Use Cases:
for use this Block is invoked.
Directly after a connection is established and before it is made available
:on_connect [Proc]

Default: 3
supplied block should a connection failure occurr during the block
connection failures. This retry controls upto how many times to retry the
This is independent of :connect_retry_count which still applies with
Number of times to retry when calling #retry_on_connection_failure
:retry_count [Integer]

Default: 0.5
Number of seconds between connection retry attempts after the first failed attempt
:connect_retry_interval [Float]

Default: 10
Number of times to retry connecting when a connection fails
:connect_retry_count [Integer]

Default: true
where multiple sends are expected during a single response
Buffering is recommended in a browser or file transfer style environment
ACK from the server before sending the last partial segment
Recommend disabling for RPC style invocations where we don't want to wait for an
Whether to use Nagle's Buffering algorithm (http://en.wikipedia.org/wiki/Nagle's_algorithm)
:buffered [Boolean]

Default: SemanticLogger.default_level
:trace, :debug, :info, :warn, :error, :fatal
Any valid SemanticLogger log level:
Optional: Set the logging level for the TCPClient
:log_level [Symbol]

Default: 60
Can be overridden by supplying a timeout in the write call
Time in seconds to timeout on write
:write_timeout [Float]

Default: 60
Can be overridden by supplying a timeout in the read call
Time in seconds to timeout on read
:read_timeout [Float]

Default: Half of the :read_timeout ( 30 seconds )
A value of -1 will cause the connect wait time to be infinite
Time in seconds to timeout when trying to connect to the server
:connect_timeout [Float]

server, only a connection failure or during an automatic reconnect
A read failure or timeout will not result in switching to the second
cannot be connected to or has timed out on connect
The second server will only be attempted once the first server

['server1:2000', 'server2:2000']
Array of URL's of servers to connect to with port numbers
:servers [Array of String]

'192.168.1.10:80'
'localhost:2000'
URL of the server to connect to with port number
:server [String]
Net::TCPClient Parameters:

Create TCP log appender.
def initialize(separator: "\n",
               level: nil, formatter: nil, filter: nil, application: nil, environment: nil, host: nil, metrics: false,
               **tcp_client_args, &block)
  @separator       = separator
  @tcp_client_args = tcp_client_args
  # Use the internal logger so that errors with remote logging are only written locally.
  Net::TCPClient.logger      = logger
  Net::TCPClient.logger.name = "Net::TCPClient"
  super(level: level, formatter: formatter, filter: filter, application: application, environment: environment, host: host, metrics: metrics, &block)
  reopen
end

def log(log)

Write the log using the specified protocol and server.
def log(log)
  message = formatter.call(log, self)
  @tcp_client.retry_on_connection_failure do
    @tcp_client.write("#{message}#{separator}")
  end
  true
end

def reopen

After forking an active process call #reopen to re-open the handles to resources.
def reopen
  close
  @tcp_client = Net::TCPClient.new(**@tcp_client_args)
end