Class: Gruf::Interceptors::Instrumentation::RequestLogging::Formatters::Plain
- Inherits:
-
Base
- Object
- Base
- Gruf::Interceptors::Instrumentation::RequestLogging::Formatters::Plain
- Defined in:
- lib/gruf/interceptors/instrumentation/request_logging/formatters/plain.rb
Overview
Formats the request into plaintext logging
Instance Method Summary collapse
-
#format(payload, request:, result:) ⇒ String
Format the request by only outputting the message body and params (if set to log params).
Instance Method Details
#format(payload, request:, result:) ⇒ String
Format the request by only outputting the message body and params (if set to log params)
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/gruf/interceptors/instrumentation/request_logging/formatters/plain.rb', line 35 def format(payload, request:, result:) time = payload.fetch(:duration, 0) grpc_status = payload.fetch(:grpc_status, 'GRPC::Ok') route_key = payload.fetch(:method, 'unknown') body = payload.fetch(:message, '') msg = "[#{grpc_status}] (#{route_key}) [#{time}ms] #{body}".strip msg += " Parameters: #{payload[:params].to_h}" if payload.key?(:params) msg.strip end |