Sha256: 8a4d989c8f6ab9d5de807a9a1bc19791f2e10a7a8a20448c5022dc010c209d5f

Contents?: true

Size: 689 Bytes

Versions: 4

Compression:

Stored size: 689 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..2000]}| response |#{result.inspect[0..2000]}| - (#{end_time}s)"
      result
    end

    def public_send(name, *args)
      method_missing(name, *args)
    end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
3scale_toolbox-0.19.0 lib/3scale_toolbox/proxy_logger.rb
3scale_toolbox-0.18.3 lib/3scale_toolbox/proxy_logger.rb
3scale_toolbox-0.18.2 lib/3scale_toolbox/proxy_logger.rb
3scale_toolbox-0.18.0 lib/3scale_toolbox/proxy_logger.rb