Set up logging before database

This commit is contained in:
José Rebelo
2026-05-22 21:54:41 +01:00
parent a1b243ca69
commit f317b744eb
@@ -230,11 +230,13 @@ public class GBApplication extends Application {
sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
prefs = new GBPrefs(sharedPrefs); prefs = new GBPrefs(sharedPrefs);
if (!GBEnvironment.isEnvironmentSetup()) { final boolean environmentSetup = GBEnvironment.isEnvironmentSetup();
// We need to set up the environment before initializing logging, so that the logging
// path is properly set, and we should set up logging before the database setup, so that
// the database upgrade also gets logged as expected.
if (!environmentSetup) {
GBEnvironment.setupEnvironment(GBEnvironment.createDeviceEnvironment()); GBEnvironment.setupEnvironment(GBEnvironment.createDeviceEnvironment());
// setup db after the environment is set up, but don't do it in test mode
// in test mode, it's done individually, see TestBase
GBDatabaseManager.setupDatabase(this);
} }
Logging.getInstance().initialize( Logging.getInstance().initialize(
@@ -242,6 +244,12 @@ public class GBApplication extends Application {
prefs.getBoolean("log_level_trace", false) prefs.getBoolean("log_level_trace", false)
); );
if (!environmentSetup) {
// setup db after the environment is set up, but don't do it in test mode
// in test mode, it's done individually, see TestBase
GBDatabaseManager.setupDatabase(this);
}
migratePrefsIfNeeded(); migratePrefsIfNeeded();
setupExceptionHandler(prefs.getBoolean("crash_notification", isDebug())); setupExceptionHandler(prefs.getBoolean("crash_notification", isDebug()));