Package com.guinetik.rr.util
Class ResponseLogger
- java.lang.Object
-
- com.guinetik.rr.util.ResponseLogger
-
public final class ResponseLogger extends Object
Utility class for configurable HTTP response logging.This class provides methods for logging HTTP response details based on
RocketRestOptionsconfiguration. It supports logging status codes, headers, and response bodies with configurable truncation for large responses.Logging Configuration
RocketRestOptions options = new RocketRestOptions(); // Enable/disable logging options.set(RocketRestOptions.LOGGING_ENABLED, true); // Enable raw response logging (status + headers) options.set(RocketRestOptions.LOG_RAW_RESPONSE, true); // Enable body logging options.set(RocketRestOptions.LOG_RESPONSE_BODY, true); // Set max body length before truncation options.set(RocketRestOptions.MAX_LOGGED_BODY_LENGTH, 4000);Usage in HTTP Clients
// After receiving response Map<String, String> headers = parseHeaders(connection); ResponseLogger.logRawResponse(statusCode, headers, options); String body = readResponseBody(connection); ResponseLogger.logResponseBody(body, options);- Since:
- 1.0.0
- Author:
- guinetik <guinetik@gmail.com>
- See Also:
RocketRestOptions
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidlogRawResponse(int statusCode, Map<String,String> headers, RocketRestOptions clientOptions)Logs the raw HTTP response if enabled in the client options.static voidlogResponseBody(String responseBody, RocketRestOptions clientOptions)Logs the response body if enabled in the client options.
-
-
-
Method Detail
-
logRawResponse
public static void logRawResponse(int statusCode, Map<String,String> headers, RocketRestOptions clientOptions)Logs the raw HTTP response if enabled in the client options.- Parameters:
statusCode- The HTTP status codeheaders- The response headersclientOptions- The client options
-
logResponseBody
public static void logResponseBody(String responseBody, RocketRestOptions clientOptions)
Logs the response body if enabled in the client options.- Parameters:
responseBody- The response body as a stringclientOptions- The client options
-
-