class Gruf::Interceptors::Instrumentation::RequestLogging::Formatters::Plain
Formats the request into plaintext logging
Public Instance Methods
format(payload, request:, result:)
click to toggle source
Format the request by only outputting the message body and params (if set to log params)
@param [Hash] payload The incoming request payload @param [Gruf::Controllers::Request] request The current controller request @param [Gruf::Interceptors::Timer::Result] result The timed result of the response @return [String] The formatted string
# 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