lib/semantic_logger/appender/tcp.rb in semantic_logger-4.2.0 vs lib/semantic_logger/appender/tcp.rb in semantic_logger-4.2.1

- old
+ new

@@ -179,35 +179,15 @@ # appender: :tcp, # server: 'server:3300', # connect_retry_interval: 0.1, # connect_retry_count: 5 # ) - def initialize(server: nil, servers: nil, separator: "\n", - policy: :ordered, buffered: true, #keepalive: true, - connect_timeout: 10.0, read_timeout: 60.0, write_timeout: 60.0, - connect_retry_count: 10, retry_count: 3, connect_retry_interval: 0.5, close_on_error: true, - on_connect: nil, proxy_server: nil, ssl: nil, - level: nil, formatter: nil, filter: nil, application: nil, host: nil, &block - ) - @separator = separator - @options = { - server: server, - servers: servers, - policy: policy, - buffered: buffered, - #keepalive: keepalive, - connect_timeout: connect_timeout, - read_timeout: read_timeout, - write_timeout: write_timeout, - connect_retry_count: connect_retry_count, - retry_count: retry_count, - connect_retry_interval: connect_retry_interval, - close_on_error: close_on_error, - on_connect: on_connect, - proxy_server: proxy_server, - ssl: ssl - } + def initialize(separator: "\n", + level: nil, formatter: nil, filter: nil, application: nil, host: nil, + **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' @@ -216,11 +196,11 @@ end # After forking an active process call #reopen to re-open the handles to resources. def reopen close - @tcp_client = Net::TCPClient.new(@options) + @tcp_client = Net::TCPClient.new(@tcp_client_args) end # Write the log using the specified protocol and server. def log(log) message = formatter.call(log, self) @@ -230,23 +210,22 @@ true end # Flush is called by the semantic_logger during shutdown. def flush - @tcp_client.flush if @tcp_client + @tcp_client&.flush end # Close is called during shutdown, or with reopen def close - @tcp_client.close if @tcp_client + @tcp_client&.close end private # Returns [SemanticLogger::Formatters::Default] formatter default for this Appender def default_formatter SemanticLogger::Formatters::Json.new end - end end end