Class: Logging::Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/tcp_server/logging.rb

Overview

The Proxy class

Constant Summary collapse

SEVERITIES =
i[trace debug info warn error fatal].freeze

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



282
283
284
285
286
287
288
289
290
291
292
# File 'lib/tcp_server/logging.rb', line 282

def method_missing(method_name, *args, &block)
  return super unless SEVERITIES.include?(method_name)

  receiver = Thread.current[:logging_receiver]
  callsite = Thread.current[:logging_callsite] || caller_locations(2, 1).first
  category = Logging.derive_category(receiver, callsite)

  Logging.with_category(category) do
    Logging.dispatch(method_name, *args, &block)
  end
end

Instance Method Details

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


294
295
296
# File 'lib/tcp_server/logging.rb', line 294

def respond_to_missing?(method_name, include_private = false)
  SEVERITIES.include?(method_name) || super
end