mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-25 18:15:49 +01:00
Add another safeguard to prevent unintended slf4j setup
This commit is contained in:
parent
f7ecb5a867
commit
65e054a747
@ -61,6 +61,10 @@ public abstract class Logging {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isFileLoggerInitialized() {
|
||||
return fileLogger != null;
|
||||
}
|
||||
|
||||
public void debugLoggingConfiguration() {
|
||||
// For debugging problems with the logback configuration
|
||||
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
|
||||
|
@ -31,6 +31,7 @@ import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.Html;
|
||||
import android.text.SpannableString;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@ -98,6 +99,8 @@ public class GB {
|
||||
|
||||
private static boolean notificationChannelsCreated;
|
||||
|
||||
private static final String TAG = "GB";
|
||||
|
||||
public static void createNotificationChannels(Context context) {
|
||||
if (notificationChannelsCreated) return;
|
||||
|
||||
@ -459,6 +462,18 @@ public class GB {
|
||||
}
|
||||
|
||||
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) {
|
||||
case INFO:
|
||||
LOG.info(message, ex);
|
||||
|
Loading…
Reference in New Issue
Block a user