/** * Logs the specified request and response information. * * <p>Note that in order to avoid any temptation to consume the contents of the response, this * does <em>not</em> take an {@link com.google.api.client.http.HttpResponse} object, but instead * accepts the status code and message from the response. */ public void logRequest( @Nullable HttpRequest request, int statusCode, @Nullable String statusMessage) { boolean isSuccess = HttpStatusCodes.isSuccess(statusCode); if (!loggerDelegate.isSummaryLoggable(isSuccess) && !loggerDelegate.isDetailsLoggable(isSuccess)) { return; } // Populate the RequestInfo builder from the request. RequestInfo requestInfo = buildRequestInfo(request); // Populate the ResponseInfo builder from the response. ResponseInfo responseInfo = buildResponseInfo(request, statusCode, statusMessage); RemoteCallReturn.Builder remoteCallReturnBuilder = new RemoteCallReturn.Builder().withRequestInfo(requestInfo).withResponseInfo(responseInfo); if (!isSuccess) { remoteCallReturnBuilder.withException( new ReportException(String.format("%s: %s", statusCode, statusMessage))); } RemoteCallReturn remoteCallReturn = remoteCallReturnBuilder.build(); loggerDelegate.logRequestSummary(remoteCallReturn); loggerDelegate.logRequestDetails(remoteCallReturn); }
/** * Logs the specified request and response information. * * <p>Note that in order to avoid any temptation to consume the contents of the response, this * does <em>not</em> take an {@link com.google.api.client.http.HttpResponse} object, but instead * accepts the status code and message from the response. */ public void logRequest( @Nullable HttpRequest request, int statusCode, @Nullable String statusMessage) { boolean isSuccess = HttpStatusCodes.isSuccess(statusCode); if (!loggerDelegate.isSummaryLoggable(isSuccess) && !loggerDelegate.isDetailsLoggable(isSuccess)) { return; } // Populate the RequestInfo builder from the request. RequestInfo requestInfo = buildRequestInfo(request); // Populate the ResponseInfo builder from the response. ResponseInfo responseInfo = buildResponseInfo(request, statusCode, statusMessage); RemoteCallReturn.Builder remoteCallReturnBuilder = new RemoteCallReturn.Builder().withRequestInfo(requestInfo).withResponseInfo(responseInfo); if (!isSuccess) { remoteCallReturnBuilder.withException( new ReportException(String.format("%s: %s", statusCode, statusMessage))); } RemoteCallReturn remoteCallReturn = remoteCallReturnBuilder.build(); loggerDelegate.logRequestSummary(remoteCallReturn); loggerDelegate.logRequestDetails(remoteCallReturn); }
if (!isSummaryLoggable(isSuccess)) { return;
if (!isSummaryLoggable(isSuccess)) { return;