What StackTraceElements does "new Throwable().getStackTrace()" return?

154 views Asked by At

The reason i ask what StackTraceElements are returned by new Throwable().getStackTrace() returns is because Timber#getTag method assumes that the 6th StackTraceElement is source of the log... e.g: new Throwable().getStackTrace()[5] == MainFragment Class or new Throwable().getStackTrace()[5] == Logging Class

Note: new Throwable().getStackTrace() is called at Timber#getTag, not where we are logging. While logging, we sometimes doesn't even pass a Throwable ( Timber.d("Fetching restaurants.") )

0

There are 0 answers