From 97812e1501a282e62cac67f96936b0521ca91986 Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Wed, 10 Jun 2020 13:25:22 +0200 Subject: [PATCH] Convert more prints to logs This way they will show up in the LogViewer --- lib/analytics.dart | 8 ++++---- lib/app.dart | 3 --- lib/core/notes_cache.dart | 2 +- lib/error_reporting.dart | 5 ++--- lib/setup/autoconfigure.dart | 6 +++--- lib/state_container.dart | 2 +- lib/widgets/note_viewer.dart | 3 ++- 7 files changed, 13 insertions(+), 16 deletions(-) diff --git a/lib/analytics.dart b/lib/analytics.dart index c85b5949..a40dc75b 100644 --- a/lib/analytics.dart +++ b/lib/analytics.dart @@ -103,7 +103,7 @@ class CustomRouteObserver extends RouteObserver> { if (route is PageRoute) { _sendScreenView(route); } else { - print("route in not a PageRoute! $route"); + // print("route in not a PageRoute! $route"); } } @@ -113,7 +113,7 @@ class CustomRouteObserver extends RouteObserver> { if (newRoute is PageRoute) { _sendScreenView(newRoute); } else { - print("newRoute in not a PageRoute! $newRoute"); + // print("newRoute in not a PageRoute! $newRoute"); } } @@ -123,8 +123,8 @@ class CustomRouteObserver extends RouteObserver> { if (previousRoute is PageRoute && route is PageRoute) { _sendScreenView(previousRoute); } else { - print("previousRoute in not a PageRoute! $previousRoute"); - print("route in not a PageRoute! $route"); + // print("previousRoute in not a PageRoute! $previousRoute"); + // print("route in not a PageRoute! $route"); } } } diff --git a/lib/app.dart b/lib/app.dart index 2484dcc5..753cf391 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -194,13 +194,10 @@ class _JournalAppState extends State { ), ]); - print("Nav key $_navigatorKey"); - _initShareSubscriptions(); } void _afterBuild(BuildContext context) { - print("_afterBuild $_pendingShortcut"); if (_pendingShortcut != null) { _navigatorKey.currentState.pushNamed("/newNote/$_pendingShortcut"); _pendingShortcut = null; diff --git a/lib/core/notes_cache.dart b/lib/core/notes_cache.dart index 49dd4805..ea441fd5 100644 --- a/lib/core/notes_cache.dart +++ b/lib/core/notes_cache.dart @@ -67,7 +67,7 @@ class NotesCache { Future buildCache(NotesFolderFS rootFolder) async { if (!enabled) return; - print("Saving the NotesCache"); + Log.d("Saving the NotesCache"); var notes = rootFolder.getAllNotes(); var sortingMode = rootFolder.config.sortingMode; diff --git a/lib/error_reporting.dart b/lib/error_reporting.dart index c8101c76..bbb209a2 100644 --- a/lib/error_reporting.dart +++ b/lib/error_reporting.dart @@ -93,12 +93,11 @@ Future initCrashlytics() async { } Future reportError(Object error, StackTrace stackTrace) async { + Log.e("Uncaught Exception", ex: error, stacktrace: stackTrace); + if (reportCrashes) { captureSentryException(error, stackTrace); } - - print("Uncaught Exception: $error"); - print(stackTrace); } // Dart makes a distiction between Errors and Exceptions diff --git a/lib/setup/autoconfigure.dart b/lib/setup/autoconfigure.dart index b0330833..b35fda55 100644 --- a/lib/setup/autoconfigure.dart +++ b/lib/setup/autoconfigure.dart @@ -71,9 +71,9 @@ class GitHostSetupAutoConfigureState extends State { try { await gitHost.launchOAuthScreen(); } on PlatformException catch (e, stack) { - print("LaunchOAuthScreen: Caught platform exception: " + e.toString()); - print(stack); - print("Ignoring it, since I don't know what else to do"); + Log.d("LaunchOAuthScreen: Caught platform exception:", + ex: e, stacktrace: stack); + Log.d("Ignoring it, since I don't know what else to do"); } } on Exception catch (e, stacktrace) { _handleGitHostException(e, stacktrace); diff --git a/lib/state_container.dart b/lib/state_container.dart index b5e9c3c7..b9f15326 100644 --- a/lib/state_container.dart +++ b/lib/state_container.dart @@ -188,7 +188,7 @@ class StateContainer with ChangeNotifier { Log.d("Got renameFolder lock"); var oldFolderPath = folder.folderPath; - print("Renaming Folder from $oldFolderPath -> $newFolderName"); + Log.d("Renaming Folder from $oldFolderPath -> $newFolderName"); folder.rename(newFolderName); _gitRepo diff --git a/lib/widgets/note_viewer.dart b/lib/widgets/note_viewer.dart index 4d3516ca..647007cb 100644 --- a/lib/widgets/note_viewer.dart +++ b/lib/widgets/note_viewer.dart @@ -6,6 +6,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; import 'package:gitjournal/folder_views/common.dart'; import 'package:gitjournal/utils.dart'; +import 'package:gitjournal/utils/logger.dart'; import 'package:gitjournal/widgets/editor_scroll_view.dart'; import 'package:gitjournal/widgets/notes_backlinks.dart'; import 'package:provider/provider.dart'; @@ -68,7 +69,7 @@ class NoteViewer extends StatelessWidget { showSnackbar(context, "Link '$link' not found"); } } else { - print("Launching " + link); + Log.i("Launching $link"); launch(link); } },