patterntesting.runtime.log
Class PerfLogger

Package class diagram package PerfLogger
java.lang.Object
  extended by patterntesting.runtime.log.PerfLogger

public final class PerfLogger
extends Object

This class is a kind of performance logger to be able to log the execution times of methods or code segments which may need a little bit longer. It can be used as a replacement of a normal logger.

We use a LogWatch to measure the times between a start(String, Object...) and end(String, Object...) call. We store this LogWatch as ThreadLocal because loggers are normally used as static variables. So we can be sure that each thread has its own LogWatch.

Since:
1.4.1 (17.03.2014)
Version:
$Revision: 1.8 $
Author:
oliver

Constructor Summary
PerfLogger()
          Instantiates a new perf logger.
PerfLogger(Class<?> clazz)
          Instantiates a new perf logger.
PerfLogger(org.slf4j.Logger logger)
          Instantiates a new perf logger.
 
Method Summary
 void debug(String format, Object... args)
          Debug.
 void end(int level, String format, Object... args)
          End the log with the given message.
 void end(String format, Object... args)
          End the log with the given message.
 void error(String format, Object... args)
          Error.
 void info(String format, Object... args)
          Info.
 boolean isDebugEnabled()
          Checks if is debug enabled.
 void log(int level, String format, Object... args)
          Log.
 void start(int level, String format, Object... args)
          Start the log for the given message.
 void start(String format, Object... args)
          Start the log for the given message.
 void stop(ProfileMonitor mon, String command)
          Deprecated. moved to SqlStatistic class
 void stop(ProfileMonitor mon, String command, Object returnValue)
          Deprecated. moved to SqlStatistic class
 void trace(String format, Object... args)
          Trace.
 void warn(String format, Object... args)
          Warn.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PerfLogger

public PerfLogger()
Instantiates a new perf logger.


PerfLogger

public PerfLogger(Class<?> clazz)
Instantiates a new perf logger.

Parameters:
clazz - the clazz

PerfLogger

public PerfLogger(org.slf4j.Logger logger)
Instantiates a new perf logger.

Parameters:
logger - the logger
Method Detail

start

public void start(String format,
                  Object... args)
Start the log for the given message. The default level for the logged message is "INFO".

Parameters:
format - the format
args - the args

start

public void start(int level,
                  String format,
                  Object... args)
Start the log for the given message. For the valid log levels see

Parameters:
level - the level
format - the format
args - the args SimpleLog.
See Also:
SimpleLog

end

public void end(String format,
                Object... args)
End the log with the given message. The output will contain the measure time from the last start(String, Object...) log. So be sure to call one of the start methods before.

The default level for the logged message is "INFO".

Parameters:
format - the format
args - the args

end

public void end(int level,
                String format,
                Object... args)
End the log with the given message. The output will contain the measure time from the last start(String, Object...) log. So be sure to call one of the start methods before.

It is recommended to use the same as in

Parameters:
level - the level
format - the format
args - the args start(int, String, Object...). If the reported times is greater than 1 minute the log level will be increased at least to "INFO".


log

public void log(int level,
                String format,
                Object... args)
Log.

Parameters:
level - the level
format - the format
args - the args

error

public void error(String format,
                  Object... args)
Error.

Parameters:
format - the format
args - the args

warn

public void warn(String format,
                 Object... args)
Warn.

Parameters:
format - the format
args - the args

info

public void info(String format,
                 Object... args)
Info.

Parameters:
format - the format
args - the args

debug

public void debug(String format,
                  Object... args)
Debug.

Parameters:
format - the format
args - the args

stop

@Deprecated
public void stop(ProfileMonitor mon,
                            String command)
Deprecated. moved to SqlStatistic class

Stops the given 'mon' and logs the given command with the needed time if debug is enabled.

Parameters:
mon - the mon
command - the command

stop

@Deprecated
public void stop(ProfileMonitor mon,
                            String command,
                            Object returnValue)
Deprecated. moved to SqlStatistic class

Stops the given 'mon' and logs the given command with the needed time if debug is enabled.

Parameters:
mon - the mon
command - the command
returnValue - the return value

trace

public void trace(String format,
                  Object... args)
Trace.

Parameters:
format - the format
args - the args

isDebugEnabled

public boolean isDebugEnabled()
Checks if is debug enabled.

Returns:
true, if is debug enabled


Copyright © 2002–2014 PatternTesting Team. All rights reserved.