-
public class SafeTraceThis is a wrapper for androidx.tracing.Trace that should be used instead as beginSection and safeTrace automatically truncate the label at 127 characters instead of crashing.
SafeTrace also provides isTraceable, isCurrentlyTracing and MAX_LABEL_LENGTH.
All tracing methods check that isTraceable is true before delegating to androidx.tracing.Trace which would otherwise default to crashing if the reflection based backport fail.
-
-
Field Summary
Fields Modifier and Type Field Description private final static BooleanisTraceableprivate final static BooleanisCurrentlyTracingprivate final IntegerMAX_LABEL_LENGTHpublic final static SafeTraceINSTANCE
-
Method Summary
Modifier and Type Method Description final static UnitforceTraceable()final static UnitbeginSection(String label)Writes a trace message to indicate that a given section of code has begun. final static UnitbeginSection(Function0<String> labelLambda)final static UnitlogSection(String label)Begins and ends a section immediately. final static UnitlogSection(Function0<String> labelLambda)final static UnitendSection()Writes a trace message to indicate that a given section of code has ended. final static UnitbeginAsyncSection(Function0<Pair<String, Integer>> labelCookiePairLambda)final static UnitbeginAsyncSection(String label, Integer cookie)cookie defaults to 0 (cookie is used for async traces that overlap) final static UnitendAsyncSection(String label, Integer cookie)cookie defaults to 0 (cookie is used for async traces that overlap) final static UnitendAsyncSection(Function0<Pair<String, Integer>> labelCookiePairLambda)final static BooleangetIsTraceable()final static BooleangetIsCurrentlyTracing()final IntegergetMAX_LABEL_LENGTH()android.os.Trace.beginSection throws IllegalArgumentException if the label is longer than 127 characters. -
-
Method Detail
-
forceTraceable
final static Unit forceTraceable()
-
beginSection
final static Unit beginSection(String label)
Writes a trace message to indicate that a given section of code has begun. This call must be followed by a corresponding call to {@link #endSection()} on the same thread.
-
beginSection
final static Unit beginSection(Function0<String> labelLambda)
-
logSection
final static Unit logSection(String label)
Begins and ends a section immediately. Useful for reporting information in the trace.
-
logSection
final static Unit logSection(Function0<String> labelLambda)
-
endSection
final static Unit endSection()
Writes a trace message to indicate that a given section of code has ended. This call must be preceded by a corresponding call to {@link #beginSection(String)}. Calling this method will mark the end of the most recently begun section of code, so care must be taken to ensure that beginSection / endSection pairs are properly nested and called from the same thread.
-
beginAsyncSection
final static Unit beginAsyncSection(Function0<Pair<String, Integer>> labelCookiePairLambda)
-
beginAsyncSection
final static Unit beginAsyncSection(String label, Integer cookie)
cookie defaults to 0 (cookie is used for async traces that overlap)
-
endAsyncSection
final static Unit endAsyncSection(String label, Integer cookie)
cookie defaults to 0 (cookie is used for async traces that overlap)
-
endAsyncSection
final static Unit endAsyncSection(Function0<Pair<String, Integer>> labelCookiePairLambda)
-
getIsTraceable
final static Boolean getIsTraceable()
-
getIsCurrentlyTracing
final static Boolean getIsCurrentlyTracing()
-
getMAX_LABEL_LENGTH
final Integer getMAX_LABEL_LENGTH()
android.os.Trace.beginSection throws IllegalArgumentException if the label is longer than 127 characters.
public so that to allowing building strings differently to avoid trailing characters being removed.
-
-
-
-