nazrinharris / pecunia

Massively ambitious personal finance app.
1 stars 0 forks source link

Improve logging that includes the `StackTrace` #11

Closed nazrinharris closed 1 year ago

nazrinharris commented 1 year ago

Having the StackTrace is very useful when debugging, but I don't particularly need the whole StackTrace to begin with. Maybe a few lines of it would've been enough. It seems like I can achieve this with the stack_trace package.

Deed

nazrinharris commented 1 year ago

I've improved it somewhat by using the stack_trace package. It kinda folds up stuff to make it more concise and other thingy majigs.

Before

flutter: #0      GotrueFetch.request (package:gotrue/src/fetch.dart:99:7)
flutter: <asynchronous suspension>
flutter: #1      GoTrueClient.signInWithPassword (package:gotrue/src/gotrue_client.dart:206:18)
flutter: <asynchronous suspension>
flutter: #2      SupabaseAuthRemoteDS._requestLoginWithPassword.<anonymous closure> (package:pecunia/features/auth/data/auth_remote_ds.dart:96:28)
flutter: <asynchronous suspension>
flutter: #3      new TaskEither.tryCatch.<anonymous closure> (package:fpdart/src/task_either.dart:279:30)
flutter: <asynchronous suspension>
flutter: #4      LoginWithEmailAndPassword.loginWithEmailAndPassword (package:pecunia/presentation/debug/debug_auth/providers/debug_auth_providers.dart:33:44)
flutter: <asynchronous suspension>

After

AuthFailure: Invalid login credentials
flutter: package:gotrue/src/fetch.dart 99:7                                                       GotrueFetch.request
flutter: package:gotrue/src/gotrue_client.dart 206:18                                             GoTrueClient.signInWithPassword
flutter: package:pecunia/features/auth/data/auth_remote_ds.dart 96:28                             SupabaseAuthRemoteDS._requestLoginWithPassword.<fn>
flutter: package:fpdart/src/task_either.dart 279:30                                               new TaskEither.tryCatch.<fn>
flutter: package:pecunia/presentation/debug/debug_auth/providers/debug_auth_providers.dart 33:44  LoginWithEmailAndPassword.loginWithEmailAndPassword
flutter:

With the toString() method like such:

  @override
  String toString() {
    final terse = Trace.from(stackTrace).terse;
    return 'AuthFailure: $message \n$terse';
  }
nazrinharris commented 1 year ago

I think it's good enough for now. Done with ec61998 in #13