public class ProcessLogger extends Object
Constructor and Description |
---|
ProcessLogger() |
Modifier and Type | Method and Description |
---|---|
static void |
addExtra(String traceName,
Object message)
Append an informational message to a process trace.
|
static void |
countBegin(String name)
Mark the start of a new countable operation on all active process traces.
|
static void |
countBegin(String traceName,
String name)
Mark the start of a new countable operation on an active process trace.
|
static void |
countEnd(String name,
String detail)
Mark the end of a countable operation previously reported via
countBegin(String) . |
static void |
countEnd(String traceName,
String name,
String detail)
Mark the end of a countable operation previously reported via
countBegin(String, String) . |
static <T> T |
follow(String name,
String processDescription,
Boolean verbose,
Callable<T> callableProcess)
Follow a callable process.
|
static <T> T |
follow(String name,
String processDescription,
Callable<T> callableProcess)
Follow a callable process using the system default verbose setting.
|
static String |
intervalToString(long millis)
Print a human readable time duration.
|
static boolean |
isTraceActive()
Determine if any process traces are active on the current thread.
|
static boolean |
isTraceActive(String name)
Determine if a process trace is active on the current thread.
|
static boolean |
isVerbose(String name)
Determine if the named process is active on the current thread with the verbose flag set to
true.
|
static String |
memoryToString(long free,
long tot,
long max)
Get a human readable representation of the system memory.
|
static long |
ntrace(String prefix,
String suffix,
long interval)
Count instances of a typically fast operation that may become expensive given a high number
of executions.
|
static long |
ntrace(String prefix,
String suffix,
long interval,
long threshold)
Count instances of a typically fast operation that may become expensive given a high number
of executions.
|
static long |
ntrace(String name,
String prefix,
String suffix,
long interval)
Count instances of a typically fast operation that may become expensive given a high number
of executions.
|
static long |
ntrace(String name,
String prefix,
String suffix,
long interval,
long threshold)
Count instances of a typically fast operation that may become expensive given a high number
of executions.
|
static <T> T |
safeFollow(String name,
String processDescription,
Boolean verbose,
Callable<T> callableProcess)
Follow a callable process with checked exception handling.
|
static <T> T |
safeFollow(String name,
String processDescription,
Callable<T> callableProcess)
Follow a callable process using the system default verbose setting and checked exception
handling.
|
static void |
setVerbose(String name,
boolean verbose)
Modify the verbose flag on a process trace active on the current thread.
|
static String |
sizeToString(long bytes)
Print a human readable size.
|
static void |
trace(String message)
Report a trace message on all process traces active on the current thread.
|
static void |
trace(String name,
String message)
Report a trace message on a process trace, if active on the current thread.
|
public ProcessLogger()
public static String intervalToString(long millis)
millis
- The number of milliseconds.public static String sizeToString(long bytes)
bytes
- The number of bytes.public static String memoryToString(long free, long tot, long max)
free
- free heap memory, in bytestot
- total heap memory, in bytesmax
- maximum total heap memory, in bytespublic static <T> T safeFollow(String name, String processDescription, Callable<T> callableProcess)
T
- callable return typename
- The name of the process.processDescription
- A message describing the process to report at the top of the trace.callableProcess
- The callable process.IllegalStateException
- If checked exception occurs within the callable process.public static <T> T safeFollow(String name, String processDescription, Boolean verbose, Callable<T> callableProcess)
T
- callable return typename
- The name of the process.processDescription
- A message describing the process to report at the top of the trace.verbose
- Verbose operation flag, see ProcessStatus#verbose
.callableProcess
- The callable process.IllegalStateException
- If checked exception occurs within the callable process.public static <T> T follow(String name, String processDescription, Callable<T> callableProcess) throws Exception
T
- callable return typename
- The name of the process.processDescription
- A message describing the process to report at the top of the trace.callableProcess
- The callable process.Exception
- from Callable.call()
public static <T> T follow(String name, String processDescription, Boolean verbose, Callable<T> callableProcess) throws Exception
T
- callable return typename
- The name of the process.processDescription
- A message describing the process to report at the top of the trace.verbose
- True to note every trace entry, false to only note those that take longer than 1ms.callableProcess
- The callable process.Exception
- from Callable.call()
public static boolean isTraceActive()
public static boolean isTraceActive(String name)
name
- The name of the process trace.public static boolean isVerbose(String name)
name
- The name of the process trace.public static void setVerbose(String name, boolean verbose)
This method has no impact if a process trace with the given name is not active.
name
- The name of the process trace.verbose
- The verbose flag setting to apply to the named process trace.public static void trace(String message)
The first 40 characters of the message will be printed on the traces along with timing and heap utilization statistics.
When debug logging is enabled, the entire message will be printed via log4j at the DEBUG level.
message
- The message to report on the trace.public static void trace(String name, String message)
The first 40 characters of the message will be printed on the trace along with timing and heap utilization statistics.
When debug logging is enabled, the entire message will be printed via log4j at the DEBUG level.
name
- The name of the process trace.message
- The message to report on the trace.public static long ntrace(String prefix, String suffix, long interval)
When the specified number of instances of the same operation have been counted, then a message indicating the execution count will be added to the process trace.
prefix
- The message to report before the count.suffix
- The message to report after the count.interval
- The number of instances to count between reports on the process trace.public static long ntrace(String prefix, String suffix, long interval, long threshold)
When the specified number of instances of the same operation have been counted, then a message indicating the execution count will be added to the process trace.
prefix
- The message to report before the count.suffix
- The message to report after the count.interval
- The number of instances to count between reports on the process trace.threshold
- The number of instances below which not to report monitored counts.public static long ntrace(String name, String prefix, String suffix, long interval)
When the specified number of instances of the same operation have been counted, then a message indicating the execution count will be added to the process trace.
name
- The name of the trace.prefix
- The message to report before the count.suffix
- The message to report after the count.interval
- The number of instances to count between reports on the process trace.public static long ntrace(String name, String prefix, String suffix, long interval, long threshold)
When the specified number of instances of the same operation have been counted, then a message indicating the execution count will be added to the process trace.
name
- The name of the trace.prefix
- The message to report before the count.suffix
- The message to report after the count.interval
- The number of instances to count between reports on the process trace.threshold
- The number of instances below which not to report monitored counts.public static void countBegin(String name)
name
- The name of the process counter.public static void countBegin(String traceName, String name)
traceName
- The name of the process trace.name
- The name of the process counter.public static void countEnd(String name, String detail)
countBegin(String)
.name
- The name of the process counter.detail
- Details on the operation that just ended.public static void countEnd(String traceName, String name, String detail)
countBegin(String, String)
.traceName
- The name of the process trace.name
- The name of the process counter.detail
- Details on the operation that just ended.Copyright © 2005–2016 The Kuali Foundation. All rights reserved.