Class ProcessLogger

java.lang.Object
org.kuali.rice.krad.uif.util.ProcessLogger

public class ProcessLogger extends Object
Performance monitoring log utility.
Version:
2.4
Author:
Kuali Rice Team (rice.collab@kuali.org)
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addExtra(String traceName, Object message)
    Append an informational message to a process trace.
    static void
    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
    Determine if any process traces are active on the current thread.
    static boolean
    Determine if a process trace is active on the current thread.
    static boolean
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ProcessLogger

      public ProcessLogger()
  • Method Details

    • intervalToString

      public static String intervalToString(long millis)
      Print a human readable time duration.
      Parameters:
      millis - The number of milliseconds.
      Returns:
      A human readable representation of the time interval represented by millis.
    • sizeToString

      public static String sizeToString(long bytes)
      Print a human readable size.
      Parameters:
      bytes - The number of bytes.
      Returns:
      A human readable representation of the size.
    • memoryToString

      public static String memoryToString(long free, long tot, long max)
      Get a human readable representation of the system memory.
      Parameters:
      free - free heap memory, in bytes
      tot - total heap memory, in bytes
      max - maximum total heap memory, in bytes
      Returns:
      A human readable representation of the system memory.
    • safeFollow

      public 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.
      Type Parameters:
      T - callable return type
      Parameters:
      name - The name of the process.
      processDescription - A message describing the process to report at the top of the trace.
      callableProcess - The callable process.
      Returns:
      The result of calling the process.
      Throws:
      IllegalStateException - If checked exception occurs within the callable process.
    • safeFollow

      public static <T> T safeFollow(String name, String processDescription, Boolean verbose, Callable<T> callableProcess)
      Follow a callable process with checked exception handling.
      Type Parameters:
      T - callable return type
      Parameters:
      name - The name of the process.
      processDescription - A message describing the process to report at the top of the trace.
      verbose - Verbose operation flag, see ProcessLogger.ProcessStatus.verbose.
      callableProcess - The callable process.
      Returns:
      The result of calling the process.
      Throws:
      IllegalStateException - If checked exception occurs within the callable process.
    • follow

      public static <T> T follow(String name, String processDescription, Callable<T> callableProcess) throws Exception
      Follow a callable process using the system default verbose setting.
      Type Parameters:
      T - callable return type
      Parameters:
      name - The name of the process.
      processDescription - A message describing the process to report at the top of the trace.
      callableProcess - The callable process.
      Returns:
      The result of calling the process.
      Throws:
      Exception - from Callable.call()
    • follow

      public static <T> T follow(String name, String processDescription, Boolean verbose, Callable<T> callableProcess) throws Exception
      Follow a callable process.
      Type Parameters:
      T - callable return type
      Parameters:
      name - 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.
      Returns:
      The result of calling the process.
      Throws:
      Exception - from Callable.call()
    • isTraceActive

      public static boolean isTraceActive()
      Determine if any process traces are active on the current thread.
      Returns:
      True if any process traces are active on the current thread, false if not.
    • isTraceActive

      public static boolean isTraceActive(String name)
      Determine if a process trace is active on the current thread.
      Parameters:
      name - The name of the process trace.
      Returns:
      True if the named process trace is active on the current thread, false if not.
    • isVerbose

      public static boolean isVerbose(String name)
      Determine if the named process is active on the current thread with the verbose flag set to true.
      Parameters:
      name - The name of the process trace.
      Returns:
      True if the named process trace is active on the current thread with the verbose flag set to true, false if not.
    • setVerbose

      public static void setVerbose(String name, boolean verbose)
      Modify the verbose flag on a process trace active on the current thread.

      This method has no impact if a process trace with the given name is not active.

      Parameters:
      name - The name of the process trace.
      verbose - The verbose flag setting to apply to the named process trace.
    • trace

      public static void trace(String message)
      Report a trace message on all process traces active on the current thread.

      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.

      Parameters:
      message - The message to report on the trace.
    • trace

      public static void trace(String name, String message)
      Report a trace message on a process trace, if active on the current thread.

      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.

      Parameters:
      name - The name of the process trace.
      message - The message to report on the trace.
    • ntrace

      public 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.

      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.

      Parameters:
      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.
      Returns:
      The execution count of the operation on trace with the highest number of executions.
    • ntrace

      public 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.

      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.

      Parameters:
      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.
      Returns:
      The execution count of the operation on trace with the highest number of executions.
    • ntrace

      public 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.

      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.

      Parameters:
      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.
      Returns:
      The execution count of the operation on the named trace.
    • ntrace

      public 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.

      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.

      Parameters:
      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.
      Returns:
      The execution count of the operation on the named trace.
    • countBegin

      public static void countBegin(String name)
      Mark the start of a new countable operation on all active process traces.
      Parameters:
      name - The name of the process counter.
    • countBegin

      public static void countBegin(String traceName, String name)
      Mark the start of a new countable operation on an active process trace.
      Parameters:
      traceName - The name of the process trace.
      name - The name of the process counter.
    • countEnd

      public static void countEnd(String name, String detail)
      Mark the end of a countable operation previously reported via countBegin(String) .
      Parameters:
      name - The name of the process counter.
      detail - Details on the operation that just ended.
    • countEnd

      public static void countEnd(String traceName, String name, String detail)
      Mark the end of a countable operation previously reported via countBegin(String, String) .
      Parameters:
      traceName - The name of the process trace.
      name - The name of the process counter.
      detail - Details on the operation that just ended.
    • addExtra

      public static void addExtra(String traceName, Object message)
      Append an informational message to a process trace.

      The message will additionally be logged at the INFO level.

      Parameters:
      traceName - The name of the process trace.
      message - The information message.