/** * Determines if we should log the time. * * @return true to log, false to not log. */ protected boolean shouldLog() { // default check first if (logLevel == null && logCategory == null) { return LOG.isInfoEnabled(); } // okay user have set some parameters return isLoggerEnabled(getLoggerToUse(), logLevel); }
/** * Is called to invoke the action invocation and time the execution time. * * @param invocation the action invocation. * @return the result of the action execution. * @throws Exception can be thrown from the action. */ protected String invokeUnderTiming(ActionInvocation invocation) throws Exception { long startTime = System.currentTimeMillis(); String result = invocation.invoke(); long executionTime = System.currentTimeMillis() - startTime; StringBuilder message = new StringBuilder(100); message.append("Executed action ["); String namespace = invocation.getProxy().getNamespace(); if ((namespace != null) && (namespace.trim().length() > 0)) { message.append(namespace).append("/"); } message.append(invocation.getProxy().getActionName()); message.append("!"); message.append(invocation.getProxy().getMethod()); message.append("] took ").append(executionTime).append(" ms."); doLog(getLoggerToUse(), message.toString()); return result; }