Skip to content

Commit

Permalink
fix: save log stream subscription and print all from all loggers
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinzent03 committed Oct 3, 2024
1 parent da66f9f commit 13d6f3a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion packages/supabase_flutter/lib/src/supabase.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:developer' as dev;

import 'package:async/async.dart';
import 'package:flutter/foundation.dart';
Expand Down Expand Up @@ -90,7 +91,7 @@ class Supabase {
_instance._debugEnable = debug ?? kDebugMode;

if (_instance._debugEnable) {
_log.onRecord.listen((record) {
_instance._logSubscription = Logger('supabase').onRecord.listen((record) {
if (record.level >= Level.INFO) {
debugPrint(
'${record.loggerName}: ${record.level.name}: ${record.message} ${record.error ?? ""}');
Expand Down Expand Up @@ -157,9 +158,12 @@ class Supabase {
/// Wraps the `recoverSession()` call so that it can be terminated when `dispose()` is called
late CancelableOperation _restoreSessionCancellableOperation;

StreamSubscription? _logSubscription;

/// Dispose the instance to free up resources.
Future<void> dispose() async {
await _restoreSessionCancellableOperation.cancel();
_logSubscription?.cancel();
client.dispose();
_instance._supabaseAuth.dispose();
_initialized = false;
Expand Down
2 changes: 1 addition & 1 deletion packages/supabase_flutter/lib/src/supabase_auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ class SupabaseAuth with WidgetsBindingObserver {
Future<void> _handleDeeplink(Uri uri) async {
if (!_isAuthCallbackDeeplink(uri)) return;

_log.fine('handle deeplink uri: $uri');
_log.finest('handle deeplink uri: $uri');
_log.info('handle deeplink uri');

try {
Expand Down

0 comments on commit 13d6f3a

Please sign in to comment.