Class TraceUtils


  • public class TraceUtils
    extends java.lang.Object
    Static methods useful for tracing.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String currentTime()
      Returns the current time as a yyyy-MM-dd HH:mm:ss.SSS string.
      static java.lang.String getCurrentStack()
      Returns the current stack of the caller.
      static java.lang.String getCurrentStack​(int numberOfTopFramesToRemove)
      Returns the current stack of the caller.
      static java.lang.String getSimpleId​(java.lang.Object obj)
      Returns a string consisting of the object's class name without the package part, '@' separator, and the hexadecimal identity hash code, e.g.
      static java.lang.String getStackTrace​(java.lang.Throwable t)
      Returns a stack trace of the given throwable as a string.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getCurrentStack

        @NonNull
        public static java.lang.String getCurrentStack()
        Returns the current stack of the caller.
        Returns:
        the stack as a string
      • getCurrentStack

        @NonNull
        public static java.lang.String getCurrentStack​(int numberOfTopFramesToRemove)
        Returns the current stack of the caller. Optionally, removes few frames at the top of the stack.
        Parameters:
        numberOfTopFramesToRemove - the number of top stack frames to remove
        Returns:
        the stack as a string
      • getStackTrace

        @NonNull
        public static java.lang.String getStackTrace​(@NonNull
                                                     java.lang.Throwable t)
        Returns a stack trace of the given throwable as a string.
        Parameters:
        t - the throwable to get the stack trace from
        Returns:
        the string containing the stack trace
      • getSimpleId

        @NonNull
        public static java.lang.String getSimpleId​(@Nullable
                                                   java.lang.Object obj)
        Returns a string consisting of the object's class name without the package part, '@' separator, and the hexadecimal identity hash code, e.g. AndroidResGroupNode@5A1D1719.
      • currentTime

        @NonNull
        public static java.lang.String currentTime()
        Returns the current time as a yyyy-MM-dd HH:mm:ss.SSS string.