mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 09:01:55 +01:00
Add another safeguard to prevent unintended slf4j setup
This commit is contained in:
parent
005276248f
commit
ac5f928652
@ -61,6 +61,10 @@ public abstract class Logging {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isFileLoggerInitialized() {
|
||||||
|
return fileLogger != null;
|
||||||
|
}
|
||||||
|
|
||||||
public void debugLoggingConfiguration() {
|
public void debugLoggingConfiguration() {
|
||||||
// For debugging problems with the logback configuration
|
// For debugging problems with the logback configuration
|
||||||
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
|
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
|
||||||
|
@ -31,6 +31,7 @@ import android.os.Handler;
|
|||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@ -98,6 +99,8 @@ public class GB {
|
|||||||
|
|
||||||
private static boolean notificationChannelsCreated;
|
private static boolean notificationChannelsCreated;
|
||||||
|
|
||||||
|
private static final String TAG = "GB";
|
||||||
|
|
||||||
public static void createNotificationChannels(Context context) {
|
public static void createNotificationChannels(Context context) {
|
||||||
if (notificationChannelsCreated) return;
|
if (notificationChannelsCreated) return;
|
||||||
|
|
||||||
@ -459,6 +462,18 @@ public class GB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void log(String message, int severity, Throwable ex) {
|
public static void log(String message, int severity, Throwable ex) {
|
||||||
|
|
||||||
|
// Handle if slf4j is not setup yet as this causes this issue:
|
||||||
|
// https://codeberg.org/Freeyourgadget/Gadgetbridge/issues/2394
|
||||||
|
// and similar, as reported by users via matrix chat, because
|
||||||
|
// under some conditions the FileUtils.getWritableExternalFilesDirs
|
||||||
|
// can break the slf4j rule again, but this method is used while bootstrapping
|
||||||
|
// slf4j, so catch22... and it is useful to have proper logging when slf4f is ready.
|
||||||
|
if (!GBApplication.getLogging().isFileLoggerInitialized()) {
|
||||||
|
Log.i(TAG, message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (severity) {
|
switch (severity) {
|
||||||
case INFO:
|
case INFO:
|
||||||
LOG.info(message, ex);
|
LOG.info(message, ex);
|
||||||
|
Loading…
Reference in New Issue
Block a user