use of com.google.api.ads.common.lib.client.ResponseInfo in project googleads-java-lib by googleads.
the class RemoteCallLoggerDelegate method logRequestSummary.
public void logRequestSummary(RemoteCallReturn remoteCallReturn) {
if (remoteCallReturn == null) {
return;
}
boolean isSuccess = remoteCallReturn.getException() == null;
if (!isSummaryLoggable(isSuccess)) {
return;
}
RequestInfo request = remoteCallReturn.getRequestInfo();
ResponseInfo response = remoteCallReturn.getResponseInfo();
Object[] logArgs = new Object[10];
if (request != null) {
logArgs[0] = request.getServiceName();
logArgs[1] = request.getMethodName();
logArgs[2] = request.getContextName();
logArgs[3] = request.getContextValue();
logArgs[4] = request.getUrl();
}
if (response != null) {
logArgs[5] = response.getRequestId();
logArgs[6] = response.getResponseTime();
logArgs[7] = response.getOperationsCount();
Throwable throwable = remoteCallReturn.getException();
logArgs[8] = throwable != null;
logArgs[9] = truncateThrowable(throwable, MAX_SUMMARY_ERROR_LENGTH);
}
if (isSuccess) {
summaryLogger.info(SUMMARY_TEMPLATE, logArgs);
} else {
summaryLogger.warn(SUMMARY_TEMPLATE, logArgs);
}
}
use of com.google.api.ads.common.lib.client.ResponseInfo in project googleads-java-lib by googleads.
the class RemoteCallLoggerDelegateTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
loggerDelegate = new RemoteCallLoggerDelegate(requestInfoLogger, soapXmlLogger, prettyPrinter, RemoteCallType.SOAP);
RequestInfo requestInfo = new RequestInfo.Builder().withContext("clientCustomerId", "555-555-0000").withServiceName("test service").withMethodName("test method").withUrl("http://www.example.com").withPayload(requestXml).build();
ResponseInfo responseInfo = new ResponseInfo.Builder().withRequestId("abc123def456").withOperationsCount(1_234L).withResponseTimeMillis(543_210L).withPayload(responseXml).build();
remoteCallReturn = new RemoteCallReturn.Builder().withException(null).withRequestInfo(requestInfo).withResponseInfo(responseInfo).withReturnValue("some object").build();
when(prettyPrinter.prettyPrint(requestXml)).thenReturn(prettyRequest);
when(prettyPrinter.prettyPrint(responseXml)).thenReturn(prettyResponse);
}
Aggregations