Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2005-2013 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.opensource.org/licenses/ecl2.php Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
package org.kuali.rice.kew.util;
Records and logs performance information about an elapsed time period.

Author(s):
Kuali Rice Team (rice.collab@kuali.org)
public class PerformanceLogger {
    private static final org.apache.log4j.Logger LOG =
        org.apache.log4j.Logger.getLogger(PerformanceLogger.class);
    private long startTime;
    private String documentId;
    
    public PerformanceLogger() {
        recordStartTime();
    }
    
    public PerformanceLogger(String documentId) {
        this();
        this. = documentId;
    }
    
    private void recordStartTime() {
        this. = System.currentTimeMillis();
    }
    
    public void log(String message) {
        log(messagefalse);
    }
    public void log(String messageboolean terminalPoint) {
    	if ( .isInfoEnabled() ) {
	        long endTime = System.currentTimeMillis();
	        long totalTime = endTime - ;
            String logMessage = new Formatter().format("Time: %7dms, "totalTime).toString();
            if ( != null) {
	            logMessage+="docId="++", ";
	        }
	        logMessage += message;
	        if (terminalPoint) {
	            logMessage += "\n";
	        }
	        .info(logMessage);
    	}
    }
    public void debug(String message) {
        this.debug(messagefalse);
    }
    public void debug(String messageboolean terminalPoint) {
        if ( .isDebugEnabled() ) {
            long endTime = System.currentTimeMillis();
            long totalTime = endTime - ;
            String logMessage = new Formatter().format("Time: %7dms, "totalTime).toString();
            if ( != null) {
                logMessage+="docId="++", ";
            }
            logMessage += message;
            if (terminalPoint) {
                logMessage += "\n";
            }
            .debug(logMessage);
        }
    }
New to GrepCode? Check out our FAQ X