Skip to content

Commit

Permalink
add more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
sadespresso committed Feb 24, 2025
1 parent 885b857 commit d93f536
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
30 changes: 24 additions & 6 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,23 @@ void main() async {
WidgetsFlutterBinding.ensureInitialized();

if (Platform.isWindows || Platform.isMacOS || Platform.isLinux) {
startupLog.fine("Initializing window manager");
await windowManager.ensureInitialized();
}

const String debugBuildSuffix = debugBuild ? " (dev)" : "";

unawaited(
PackageInfo.fromPlatform()
.then(
(value) =>
appVersion =
"${value.version}+${value.buildNumber}$debugBuildSuffix",
)
.then((value) {
appVersion = "${value.version}+${value.buildNumber}$debugBuildSuffix";

startupLog.fine("Loaded package info");
startupLog.fine("App version: $appVersion");
startupLog.fine("Store: ${value.installerStore}");

return appVersion;
})
.catchError((e) {
startupLog.warning(
"An error was occured while fetching app version",
Expand All @@ -101,13 +106,17 @@ void main() async {
FlowLocalizations.printMissingKeys();
}

startupLog.fine("Initializing ObjectBox database");

/// [ObjectBox] MUST initialize before [LocalPreferences] because prefs
/// access [ObjectBox] upon initialization.
await ObjectBox.initialize();
startupLog.fine("Initializing local preferences (shared prefs)");
await LocalPreferences.initialize();

/// Set `sortOrder` values if there are any unset (-1) values
await ObjectBox().updateAccountOrderList(ignoreIfNoUnsetValue: true);
startupLog.fine("Updating account order list");

unawaited(
NotificationsService().initialize().then((_) {
Expand All @@ -118,26 +127,33 @@ void main() async {
);
if (UserPreferencesService().remindDailyAt
case Duration requireRemindAt) {
startupLog.info(
"Scheduling daily reminder notifications at ${requireRemindAt.inMinutes} minutes past midnight",
);
unawaited(
NotificationsService()
.scheduleDailyReminder(requireRemindAt)
.catchError((error) {
startupLog.severe(
"Failed to schedule reminder notifications",
"Failed to schedule daily reminder notifications",
error,
);
}),
);
} else {
startupLog.fine("No daily reminder set, skipping scheduling");
}
}),
);

startupLog.fine("Clearing stale transactions from trash bin");
unawaited(
TransactionsService().clearStaleTrashBinEntries().catchError((error) {
startupLog.severe("Failed to clear stale trash bin entries", error);
}),
);

startupLog.fine("Initializing exchange rates service");
ExchangeRatesService().init();

try {
Expand All @@ -153,11 +169,13 @@ void main() async {
}

try {
startupLog.fine("Initializing user preferences service");
UserPreferencesService().initialize();
} catch (e) {
startupLog.severe("Failed to initialize UserPreferencesService", e);
}

startupLog.fine("Finally telling Flutter to run the app widget");
runApp(const Flow());
}

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: A personal finance managing app

publish_to: "none" # Remove this line if you wish to publish to pub.dev

version: "0.12.1+144"
version: "0.12.1+145"

environment:
sdk: ">=3.7.0 <4.0.0"
Expand Down

0 comments on commit d93f536

Please sign in to comment.