Sha256: ca523c2eaf009ca5a852214aeb72e5a1dbfa7d40b91ce9a8b19c8d189616d1ae

Contents?: true

Size: 661 Bytes

Versions: 14

Compression:

Stored size: 661 Bytes

Contents

module TwirpRails
  class LogSubscriber < ActiveSupport::LogSubscriber
    cattr_accessor :log_writer

    def instrumenter(event)
      if LogSubscriber.log_writer
        LogSubscriber.log_writer.call(event)
      else
        default_log_writer(event)
      end
    end

    def default_log_writer(event)
      twirp_call_info = {
        'duration' => event.duration,
        'method' => event.payload[:env][:rpc_method],
        'params' => event.payload[:env][:input].to_h
      }

      if (exception = event.payload[:env][:exception])
        twirp_call_info['exception'] = exception
      end

      Rails.logger.info twirp_call_info
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
twirp_rails-0.4.11 lib/twirp_rails/log_subscriber.rb
twirp_rails-0.4.10 lib/twirp_rails/log_subscriber.rb
twirp_rails-0.4.9 lib/twirp_rails/log_subscriber.rb
twirp_rails-0.4.8 lib/twirp_rails/log_subscriber.rb
twirp_rails-0.4.7 lib/twirp_rails/log_subscriber.rb
twirp_rails-0.4.6 lib/twirp_rails/log_subscriber.rb
twirp_rails-0.4.5 lib/twirp_rails/log_subscriber.rb
twirp_rails-0.4.4 lib/twirp_rails/log_subscriber.rb
twirp_rails-0.4.3 lib/twirp_rails/log_subscriber.rb
twirp_rails-0.4.2 lib/twirp_rails/log_subscriber.rb
twirp_rails-0.4.1 lib/twirp_rails/log_subscriber.rb
twirp_rails-0.4.0 lib/twirp_rails/log_subscriber.rb
twirp_rails-0.3.2 lib/twirp_rails/log_subscriber.rb
twirp_rails-0.3.1 lib/twirp_rails/log_subscriber.rb