Package org.apache.arrow.memory.util
Class HistoricalLog
java.lang.Object
org.apache.arrow.memory.util.HistoricalLog
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 Summary
ConstructorDescriptionHistoricalLog
(int limit, String idStringFormat, Object... args) Constructor.HistoricalLog
(String idStringFormat, Object... args) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
buildHistory
(StringBuilder sb, boolean includeStackTrace) Write the history of this object to the givenStringBuilder
.void
buildHistory
(StringBuilder sb, int indent, boolean includeStackTrace) Build the history and write it to sb.void
logHistory
(org.slf4j.Logger logger) Write the history of this object to the givenLogger
.void
recordEvent
(String noteFormat, Object... args) Record an event.
-
Constructor Details
-
HistoricalLog
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
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 madeidStringFormat
-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
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 eventargs
- for the format string, or nothing if none are required
-
buildHistory
Write the history of this object to the givenStringBuilder
. The history includes the identifying string provided at construction time, and all the recorded events with their stack traces.- Parameters:
sb
-StringBuilder
to write toincludeStackTrace
- whether to include the stacktrace of each event in the history
-
buildHistory
Build the history and write it to sb.- Parameters:
sb
- outputindent
- starting indent (usually "")includeStackTrace
- whether to include the stacktrace of each event.
-
logHistory
public void logHistory(org.slf4j.Logger logger) Write the history of this object to the givenLogger
. 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
-