Improve logging setup, should hopefully fix #107
This commit is contained in:
parent
2231dcbce3
commit
38c3a41279
|
@ -36,7 +36,6 @@ public class GBApplication extends Application {
|
||||||
|
|
||||||
public GBApplication() {
|
public GBApplication() {
|
||||||
context = this;
|
context = this;
|
||||||
deviceService = createDeviceService();
|
|
||||||
// don't do anything here, add it to onCreate instead
|
// don't do anything here, add it to onCreate instead
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,6 +58,7 @@ public class GBApplication extends Application {
|
||||||
// StatusPrinter.print(lc);
|
// StatusPrinter.print(lc);
|
||||||
// Logger logger = LoggerFactory.getLogger(GBApplication.class);
|
// Logger logger = LoggerFactory.getLogger(GBApplication.class);
|
||||||
|
|
||||||
|
deviceService = createDeviceService();
|
||||||
GB.environment = GBEnvironment.createDeviceEnvironment();
|
GB.environment = GBEnvironment.createDeviceEnvironment();
|
||||||
mActivityDatabaseHandler = new ActivityDatabaseHandler(context);
|
mActivityDatabaseHandler = new ActivityDatabaseHandler(context);
|
||||||
loadBlackList();
|
loadBlackList();
|
||||||
|
@ -79,17 +79,20 @@ public class GBApplication extends Application {
|
||||||
System.setProperty("GB_LOGFILES_DIR", dir.getAbsolutePath());
|
System.setProperty("GB_LOGFILES_DIR", dir.getAbsolutePath());
|
||||||
getLogger().info("Gadgetbridge version: " + BuildConfig.VERSION_NAME);
|
getLogger().info("Gadgetbridge version: " + BuildConfig.VERSION_NAME);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Log.e("GBApplication", "External files dir not available, cannot log to file, ex");
|
Log.e("GBApplication", "External files dir not available, cannot log to file", ex);
|
||||||
System.setProperty("GB_LOGFILES_DIR", "/dev/null");
|
removeFileLogger();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
removeFileLogger();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeFileLogger() {
|
||||||
try {
|
try {
|
||||||
ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
|
ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
|
||||||
root.detachAppender("FILE");
|
root.detachAppender("FILE");
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
System.out.println("Error removing logger FILE appender");
|
Log.e("GBApplication", "Error removing logger FILE appender", ex);
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue