@Test public void testPreHandle_LogOutput() throws Exception { HandlerMethod paramHandler = new HandlerMethod(controller, TraceLoggingInterceptorController.class .getMethod("createForm")); try { interceptor.preHandle(request, response, paramHandler); } catch (Exception e) { fail("illegal case"); } String logMessage = jdbcTemplate.queryForObject( "SELECT FORMATTED_MESSAGE FROM LOGGING_EVENT WHERE EVENT_ID=:id", Collections.singletonMap("id", 1), String.class); Long startTime = (Long) request.getAttribute( TraceLoggingInterceptor.class.getName() + ".startTime"); assertThat(logMessage, is( "[START CONTROLLER] TraceLoggingInterceptorController.createForm()")); assertThat(startTime, notNullValue()); }
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { if (!(handler instanceof HandlerMethod)) { return true; } if (logger.isTraceEnabled()) { HandlerMethod handlerMethod = (HandlerMethod) handler; Method m = handlerMethod.getMethod(); logger.trace("[START CONTROLLER] {}.{}({})", new Object[] { m .getDeclaringClass().getSimpleName(), m.getName(), buildMethodParams(handlerMethod) }); } long startTime = System.nanoTime(); request.setAttribute(START_ATTR, startTime); return true; }
TraceLoggingInterceptor implements HandlerInterceptor { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { if (!(handler instanceof HandlerMethod)) { return true; } if (logger.isTraceEnabled()) { HandlerMethod handlerMethod = (HandlerMethod) handler; Method m = handlerMethod.getMethod(); logger.trace("[START CONTROLLER] {}.{}({})", new Object[] { m .getDeclaringClass().getSimpleName(), m.getName(), buildMethodParams(handlerMethod) }); } long startTime = System.nanoTime(); request.setAttribute(START_ATTR, startTime); return true; } }
TraceLoggingInterceptor implements HandlerInterceptor { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { if (!(handler instanceof HandlerMethod)) { return true; } if (logger.isTraceEnabled()) { HandlerMethod handlerMethod = (HandlerMethod) handler; Method m = handlerMethod.getMethod(); logger.trace("[START CONTROLLER] {}.{}({})", new Object[] { m .getDeclaringClass().getSimpleName(), m.getName(), buildMethodParams(handlerMethod) }); } long startTime = System.nanoTime(); request.setAttribute(START_ATTR, startTime); return true; }  }
TraceLoggingInterceptor implements HandlerInterceptor { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { if (!(handler instanceof HandlerMethod)) { return true; } if (logger.isTraceEnabled()) { HandlerMethod handlerMethod = (HandlerMethod) handler; Method m = handlerMethod.getMethod(); logger.trace("[START CONTROLLER] {}.{}({})", new Object[] { m .getDeclaringClass().getSimpleName(), m.getName(), buildMethodParams(handlerMethod) }); } long startTime = System.nanoTime(); request.setAttribute(START_ATTR, startTime); return true; }  @Override boolean preHandle(HttpServletRequest request,
            HttpServletResponse response, Object handler); @Override void postHandle(HttpServletRequest request,
            HttpServletResponse response, Object handler,
            ModelAndView modelAndView); void setWarnHandlingNanos(long warnHandlingNanos); }
TraceLoggingInterceptor implements HandlerInterceptor { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { if (!(handler instanceof HandlerMethod)) { return true; } if (logger.isTraceEnabled()) { HandlerMethod handlerMethod = (HandlerMethod) handler; Method m = handlerMethod.getMethod(); logger.trace("[START CONTROLLER] {}.{}({})", new Object[] { m .getDeclaringClass().getSimpleName(), m.getName(), buildMethodParams(handlerMethod) }); } long startTime = System.nanoTime(); request.setAttribute(START_ATTR, startTime); return true; }  @Override boolean preHandle(HttpServletRequest request,
            HttpServletResponse response, Object handler); @Override void postHandle(HttpServletRequest request,
            HttpServletResponse response, Object handler,
            ModelAndView modelAndView); void setWarnHandlingNanos(long warnHandlingNanos);  }