Sha256: d2214be45b15dd043943c30c2efe4951d4f6b96836d64bea05987ead104a195c

Contents?: true

Size: 611 Bytes

Versions: 5

Compression:

Stored size: 611 Bytes

Contents

module ThreeScaleToolbox
  class ProxyLogger < BasicObject
    def initialize(subject)
      @subject = subject
    end

    def method_missing(name, *args)
      start_time = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
      result = @subject.public_send(name, *args)
    ensure
      end_time = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC) - start_time
      ::Kernel.puts "-- call #{name} args |#{args.inspect[0..100]}| response |#{result.inspect[0..100]}| - (#{end_time}s)"
      result
    end

    def respond_to_missing?(method_name, include_private = false)
      super
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
3scale_toolbox-0.12.2 lib/3scale_toolbox/proxy_logger.rb
3scale_toolbox-0.11.0 lib/3scale_toolbox/proxy_logger.rb
3scale_toolbox-0.10.0 lib/3scale_toolbox/proxy_logger.rb
3scale_toolbox-0.9.0 lib/3scale_toolbox/proxy_logger.rb
3scale_toolbox-0.8.0 lib/3scale_toolbox/proxy_logger.rb