use of org.apache.log4j.helpers.ISO8601DateFormat in project openmrs-module-pihcore by PIH.
the class RequestMonitoringFilter method doFilter.
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
long startTime = System.currentTimeMillis();
chain.doFilter(request, response);
long endTime = System.currentTimeMillis();
long totalTime = endTime - startTime;
if (enabled && request instanceof HttpServletRequest) {
try {
HttpServletRequest httpRequest = (HttpServletRequest) request;
HttpSession session = httpRequest.getSession();
ISO8601DateFormat dateFormat = new ISO8601DateFormat();
SimpleObject logLine = new SimpleObject();
logLine.put("timestamp", dateFormat.format(new Date(startTime)));
logLine.put("sessionId", session.getId());
logLine.put("user", session.getAttribute("username"));
logLine.put("loadTime", totalTime);
logLine.put("method", httpRequest.getMethod());
logLine.put("requestPath", httpRequest.getRequestURI());
logLine.put("queryParams", formatRequestParams(httpRequest));
logger.info(logLine.toJson());
} catch (Exception e) {
// Do nothing, we don't want this filter to cause any adverse behavior
}
}
}
use of org.apache.log4j.helpers.ISO8601DateFormat in project openmrs-module-pihcore by PIH.
the class TermsAndConditionsPageController method post.
public String post(@RequestParam(value = "termsAndConditionsAccepted", defaultValue = "false") boolean termsAndConditionsAccepted, @SpringBean("userService") UserService userService) {
if (termsAndConditionsAccepted) {
User currentUser = Context.getAuthenticatedUser();
String acceptanceDate = new ISO8601DateFormat().format(new Date());
currentUser.setUserProperty(PihCoreConstants.USER_PROPERTY_TERMS_AND_CONDITIONS_ACCEPTED_DATE, acceptanceDate);
userService.saveUser(currentUser);
}
return "redirect:/pihcore/home.page";
}
Aggregations