Sha256: ee93b670f2e979a1f67af931c533f94dd66e93969a716d57a536213f618b4668

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.warn "-- call #{name} args |#{args.inspect[0..200]}| response |#{result.inspect[0..200]}| - (#{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.15.0 lib/3scale_toolbox/proxy_logger.rb
3scale_toolbox-0.14.0 lib/3scale_toolbox/proxy_logger.rb
3scale_toolbox-0.13.0 lib/3scale_toolbox/proxy_logger.rb
3scale_toolbox-0.12.4 lib/3scale_toolbox/proxy_logger.rb
3scale_toolbox-0.12.3 lib/3scale_toolbox/proxy_logger.rb