Class HistoricalLog

java.lang.Object
org.apache.drill.common.HistoricalLog

public class HistoricalLog extends Object
Utility class that can be used to log activity within a class for later logging and debugging. Supports recording events and recording the stack at the time they occur.
  • Constructor Details

    • HistoricalLog

      public HistoricalLog(String idStringFormat, Object... args)
      Constructor. The format string will be formatted and have its arguments substituted at the time this is called.
      Parameters:
      idStringFormat - String.format(java.lang.String, java.lang.Object...) format string that can be used to identify this object in a log. Including some kind of unique identifier that can be associated with the object instance is best.
      args - for the format string, or nothing if none are required
    • HistoricalLog

      public HistoricalLog(int limit, String idStringFormat, Object... args)
      Constructor. The format string will be formatted and have its arguments substituted at the time this is called.

      This form supports the specification of a limit that will limit the number of historical entries kept (which keeps down the amount of memory used). With the limit, the first entry made is always kept (under the assumption that this is the creation site of the object, which is usually interesting), and then up to the limit number of entries are kept after that. Each time a new entry is made, the oldest that is not the first is dropped.

      Parameters:
      limit - the maximum number of historical entries that will be kept, not including the first entry made
      idStringFormat - String.format(java.lang.String, java.lang.Object...) format string that can be used to identify this object in a log. Including some kind of unique identifier that can be associated with the object instance is best.
      args - for the format string, or nothing if none are required
  • Method Details

    • recordEvent

      public void recordEvent(String noteFormat, Object... args)
      Record an event. Automatically captures the stack trace at the time this is called. The format string will be formatted and have its arguments substituted at the time this is called.
      Parameters:
      noteFormat - String.format(java.lang.String, java.lang.Object...) format string that describes the event
      args - for the format string, or nothing if none are required
    • buildHistory

      public void buildHistory(StringBuilder sb, boolean includeStackTrace)
      Write the history of this object to the given StringBuilder. The history includes the identifying string provided at construction time, and all the recorded events with their stack traces.
      Parameters:
      sb - StringBuilder to write to
      includeStackTrace - true if history includes stack trace, otherwise false
    • buildHistory

      public void buildHistory(StringBuilder sb, int indent, boolean includeStackTrace)
      Write the history of this object to the given StringBuilder. The history includes the identifying string provided at construction time, and all the recorded events with their stack traces.
      Parameters:
      sb - StringBuilder to write to
      indent - size of indent
      includeStackTrace - true if history includes stack trace, otherwise false
    • logHistory

      public void logHistory(org.slf4j.Logger logger)
      Write the history of this object to the given Logger. The history includes the identifying string provided at construction time, and all the recorded events with their stack traces.
      Parameters:
      logger - Logger to write to