Class LogNode
java.lang.Object
nonapi.io.github.classgraph.utils.LogNode
A tree-structured threadsafe log that allows you to add log entries in arbitrary order, and have the output
retain a sane order. The order may also be made deterministic by specifying a sort key for log entries.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCall this once the work corresponding with a given log entry has completed if you want to show the time taken after the log entry.voidflush()Flush out the log to stderr, and clear the log contents.Add a log entry.Add a log entry.Add a log entry.Add a log entry with sort key for deterministic ordering.Add a log entry with sort key for deterministic ordering.Add a log entry with sort key for deterministic ordering.Add a log entry with sort key for deterministic ordering.Add a log entry.Add a log entry.log(Collection<String> msgs) Add a series of log entries.static voidlogInRealtime(boolean logInRealtime) If logInRealtime is true, log entries are output in realtime, as well as added to the LogNode tree.toString()Build the log output.
-
Constructor Details
-
LogNode
public LogNode()Create a toplevel log node.
-
-
Method Details
-
logInRealtime
public static void logInRealtime(boolean logInRealtime) If logInRealtime is true, log entries are output in realtime, as well as added to the LogNode tree. This can help debug situations where log info is never shown, e.g. deadlocks, or where you need to show the log info right up to the point where you hit a breakpoint.- Parameters:
logInRealtime- whether to log in realtime
-
toString
-
addElapsedTime
public void addElapsedTime()Call this once the work corresponding with a given log entry has completed if you want to show the time taken after the log entry. -
log
Add a log entry with sort key for deterministic ordering.- Parameters:
sortKey- The sort key for the log entry.msg- The message.elapsedTimeNanos- The elapsed time.e- TheThrowablethat was thrown.- Returns:
- a child log node, which can be used to add sub-entries.
-
log
Add a log entry with sort key for deterministic ordering.- Parameters:
sortKey- The sort key for the log entry.msg- The message.elapsedTimeNanos- The elapsed time.- Returns:
- a child log node, which can be used to add sub-entries.
-
log
-
log
-
log
-
log
-
log
-
log
-
log
Add a series of log entries. Returns the last LogNode created.- Parameters:
msgs- The messages.- Returns:
- the last log node created, which can be used to add sub-entries.
-
log
-
flush
public void flush()Flush out the log to stderr, and clear the log contents. Only call this on the toplevel log node, when threads do not have access to references of internal log nodes so that they cannot add more log entries inside the tree, otherwise log entries may be lost.
-