1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-27 20:36:51 +01:00

Fix logs sometimes not containing stacktraces

Fixes #916
This commit is contained in:
cpfeiffer 2018-01-04 00:11:27 +01:00
parent b9f19970df
commit d570ee864d

View File

@ -20,6 +20,8 @@ package nodomain.freeyourgadget.gadgetbridge;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.LoggerContext;
/**
* Catches otherwise uncaught exceptions, logs them and terminates the app.
*/
@ -34,6 +36,10 @@ public class LoggingExceptionHandler implements Thread.UncaughtExceptionHandler
@Override
public void uncaughtException(Thread thread, Throwable ex) {
LOG.error("Uncaught exception: " + ex.getMessage(), ex);
// flush the log buffers and stop logging
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
loggerContext.stop();
if (mDelegate != null) {
mDelegate.uncaughtException(thread, ex);
} else {