chore: Fix debug logging if context is not set
This commit is contained in:
@ -139,14 +139,20 @@ public class Logger {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean includeStackTrace() {
|
private static boolean shouldLogDebug() {
|
||||||
return Utils.context != null && DEBUG_STACKTRACE.get();
|
// If the app is still starting up and the context is not yet set,
|
||||||
|
// then allow debug logging regardless what the debug setting actually is.
|
||||||
|
return Utils.context == null || DEBUG.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean shouldShowErrorToast() {
|
private static boolean shouldShowErrorToast() {
|
||||||
return Utils.context != null && DEBUG_TOAST_ON_ERROR.get();
|
return Utils.context != null && DEBUG_TOAST_ON_ERROR.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean includeStackTrace() {
|
||||||
|
return Utils.context != null && DEBUG_STACKTRACE.get();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs debug messages under the outer class name of the code calling this method.
|
* Logs debug messages under the outer class name of the code calling this method.
|
||||||
* <p>
|
* <p>
|
||||||
@ -166,7 +172,7 @@ public class Logger {
|
|||||||
* building strings is paid only if {@link BaseSettings#DEBUG} is enabled.
|
* building strings is paid only if {@link BaseSettings#DEBUG} is enabled.
|
||||||
*/
|
*/
|
||||||
public static void printDebug(LogMessage message, @Nullable Exception ex) {
|
public static void printDebug(LogMessage message, @Nullable Exception ex) {
|
||||||
if (DEBUG.get()) {
|
if (shouldLogDebug()) {
|
||||||
logInternal(LogLevel.DEBUG, message, ex, includeStackTrace(), false);
|
logInternal(LogLevel.DEBUG, message, ex, includeStackTrace(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user