1 /*
2 * Copyright 2011 The Kuali Foundation.
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.ole.logger;
17
18
19 import org.kuali.ole.utility.DateTimeUtil;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
22
23 /**
24 * Created by IntelliJ IDEA.
25 * User: peris
26 * Date: 8/5/11
27 * Time: 11:43 AM
28 * To change this template use File | Settings | File Templates.
29 */
30 public class MetricsLogger {
31 private long startTime;
32 private long endTime;
33 private Logger logger;
34
35 public MetricsLogger(String loggingClassName) {
36 try {
37 logger = LoggerFactory.getLogger(Class.forName(loggingClassName));
38
39 } catch (ClassNotFoundException e) {
40 System.out.println("ClassNotFoundException: " + e.getMessage());
41 }
42 }
43
44
45 public void startRecording() {
46 startTime = System.currentTimeMillis();
47 }
48
49 public void endRecording() {
50 endTime = System.currentTimeMillis();
51 }
52
53 public void printTimes(String message) {
54 logger.info(message + DateTimeUtil.formatTime(endTime - startTime));
55 }
56 }