Package com.android.utils
Class AutopsyLog
- java.lang.Object
-
- com.android.utils.AutopsyLog
-
public class AutopsyLog extends java.lang.ObjectFast in-memory log utilizing a cyclic buffer of a limited size. Intended to be used when alternative logging methods are too slow, for example, in the following scenario:- There is an expected behavior in the code, possibly caused by a race condition.
- You add logging to the code to investigate the problem.
- The problem is no longer reproducible with logging enabled.
You may try to replace the regular logging with:
AutopsyLog.initialize(100); ... AutopsyLog.log(something); ... AutopsyLog.log(somethingElse); ... if (unexpectedBehaviorDetected) { AutopsyLog.print(); }
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.List<java.lang.Object>getAndClear()Returns the contents of the log and clears the log.static voidinitialize(int sizeLimit)Initializes the log.static voidlog(java.lang.Object record)Writes a record to the log if it was initialized.static voidprint()Prints the contents of the log to stdout and clears the log.
-
-
-
Method Detail
-
initialize
public static void initialize(int sizeLimit)
Initializes the log. At most lastsizeLimitrecords will be preserved in the log. The prior contents of the log up tosizeLimitrecords are preserved.- Parameters:
sizeLimit- the maximum number of records to store
-
log
public static void log(@NonNull java.lang.Object record)Writes a record to the log if it was initialized.- Parameters:
record- an arbitrary object to log
-
getAndClear
@NonNull public static java.util.List<java.lang.Object> getAndClear()
Returns the contents of the log and clears the log.
-
print
public static void print()
Prints the contents of the log to stdout and clears the log.
-
-