use of com.jeesuite.logging.integrate.ActionLog in project jeesuite-libs by vakinge.
the class ResponseLogHandler method process.
@Override
public Object process(RequestContext ctx, HttpServletRequest request, BizSystemModule module) {
int statusCode = ctx.getResponseStatusCode();
if (statusCode != 200)
return null;
ActionLog actionLog = ActionLogCollector.currentActionLog();
if (actionLog == null)
return null;
List<Pair<String, String>> headers = ctx.getOriginResponseHeaders();
for (Pair<String, String> pair : headers) {
if (CustomRequestHeaders.HEADER_EXCEPTION_CODE.equals(pair.first())) {
actionLog.setResponseCode(Integer.parseInt(pair.second()));
break;
}
}
if (ignoreBody)
return null;
ApiInfo apiInfo = module.getApiInfo(request.getRequestURI());
if (apiInfo != null && !apiInfo.isResponseLog()) {
return null;
}
ResponseCompose responseCompose = new ResponseCompose(ctx);
ctx.set(ResponseCompose.class.getName(), responseCompose);
actionLog.setResponseData(responseCompose.getBodyString());
return null;
}
use of com.jeesuite.logging.integrate.ActionLog in project jeesuite-libs by vakinge.
the class RequestLogHandler method process.
@Override
public Object process(RequestContext ctx, HttpServletRequest request, BizSystemModule module) {
ActionLog actionLog = ActionLogCollector.currentActionLog();
if (actionLog == null)
return null;
actionLog.setModuleId(module.getServiceId());
ApiInfo apiInfo = module.getApiInfo(request.getRequestURI());
if (apiInfo != null && !apiInfo.isRequestLog()) {
return null;
}
actionLog.setQueryParameters(request.getQueryString());
if (!ignoreBody && HttpMethod.POST.name().equals(request.getMethod()) && !WebUtils.isMultipartContent(request)) {
try {
String data = CharStreams.toString(new InputStreamReader(request.getInputStream(), StandardCharsets.UTF_8));
actionLog.setRequestData(data);
} catch (Exception e) {
}
}
return null;
}
Aggregations