Module: SemanticLogger::Appender::TcpClientOptions
- Defined in:
- lib/semantic_logger/appender/tcp_client_options.rb
Overview
The options of Net::TCPClient that the :tcp appender, and the :syslog appender in tcp_client:, hand to it,
which v6 no longer takes, since it connects with a connection class of its own instead of net_tcp_client.
Defined Under Namespace
Modules: BenchmarkWithoutWarning
Constant Summary collapse
- RETRIES =
"v6 does not retry by itself, so it takes only connect_retry_count: 0 and retry_count: 0, which " \ "keep the worker thread from waiting on retries now too: the appender writes the entry again after " \ "its back-off instead, see async_max_retries:".freeze
- DEPRECATED =
Each option that v6 refuses, with why, or what to use instead.
{ connect_retry_count: RETRIES, connect_retry_interval: "#{RETRIES}, and takes connect_retry_interval: only with connect_retry_count: 0".freeze, retry_count: RETRIES, read_timeout: "the appender never reads", buffered: "v6 writes each entry at once, so it takes only buffered: false", close_on_error: "the connection is closed after any error", on_connect: "it is not called", proxy_server: "the appender does not connect through a proxy" }.freeze
- V6_VALUES =
The values of the deprecated options that v6 still takes, since they are what it does.
{connect_retry_count: 0, retry_count: 0, buffered: false}.freeze
- POLICIES =
The policies that v6 keeps, of those that Net::TCPClient takes.
%i[ordered random].freeze
- MEASURE_VERSION =
The first version of net_tcp_client that calls measure_* on its logger, rather than the deprecated benchmark_debug and benchmark_error.
Gem::Version.new("2.3.0")
Class Method Summary collapse
-
.report_deprecated(options, appender, refused = {}) ⇒ Object
Reports a deprecation warning that names each of the supplied options that v6 refuses, with why, as the options of the named appender, such as ":tcp".
-
.report_outdated_gem(appender, version = Net::TCPClient::VERSION) ⇒ Object
Returns whether the installed net_tcp_client is older than MEASURE_VERSION, after reporting a deprecation warning, as the named appender, such as ":tcp", is created, that says to update it.
Class Method Details
.report_deprecated(options, appender, refused = {}) ⇒ Object
Reports a deprecation warning that names each of the supplied options that v6 refuses, with why, as the
options of the named appender, such as ":tcp". refused names other options that v6 refuses for this
appender, with why, such as the server of the :syslog appender, which its url gives. An option given as nil
is not reported, since v6 ignores it (Net::TCPClient takes nil as the value), nor is one given a value
that v6 still takes (see V6_VALUES).
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/semantic_logger/appender/tcp_client_options.rb', line 33 def self.report_deprecated(, appender, refused = {}) reasons = DEPRECATED.merge(refused).reject { |name, _| [name].nil? || v6_value?(name, ) } policy = [:policy] unless policy.nil? || POLICIES.include?(policy) reasons[:policy] = "it takes only :ordered or :random, not #{policy.is_a?(Proc) ? 'a Proc' : policy.inspect}" end return if reasons.empty? Deprecation.warn( "The #{appender} appender's #{reasons.keys.map { |name| "#{name}:" }.join(', ')} " \ "#{reasons.one? ? 'is' : 'are'} deprecated, and v6 raises ArgumentError for " \ "#{reasons.one? ? 'it' : 'them'}, since it no longer connects with net_tcp_client: " \ "#{reasons.map { |name, reason| "#{name}: #{reason}" }.join('; ')}." ) end |
.report_outdated_gem(appender, version = Net::TCPClient::VERSION) ⇒ Object
Returns whether the installed net_tcp_client is older than MEASURE_VERSION, after reporting a deprecation warning, as the named appender, such as ":tcp", is created, that says to update it.
69 70 71 72 73 74 75 76 77 |
# File 'lib/semantic_logger/appender/tcp_client_options.rb', line 69 def self.report_outdated_gem(appender, version = Net::TCPClient::VERSION) return false unless Gem::Version.new(version) < MEASURE_VERSION Deprecation.warn( "The #{appender} appender uses net_tcp_client #{version}, which calls the deprecated benchmark_* methods " \ "at every connection and write. Update net_tcp_client to #{MEASURE_VERSION} or later, which calls measure_*." ) true end |