Skip to content

Commit

Permalink
Log top-level root logger errors
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmedLSayed9 committed Oct 18, 2024
1 parent 6ab3d6b commit 514ebdb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/core/infrastructure/services/location_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class LocationService {
timeLimit: const Duration(seconds: AppLocationSettings.getLocationTimeLimit),
);
} catch (e) {
Logger.root.shout(e.toString());
Logger.root.severe(e, StackTrace.current);
return null;
}
}
Expand Down
5 changes: 5 additions & 0 deletions lib/core/infrastructure/services/main_initializer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ Future<ProviderContainer> _mainInitializer() async {
void _setupLogger() {
hierarchicalLoggingEnabled = true;
Logger.root.level = Level.ALL;
Logger.root.onRecord.listen((LogRecord r) {
if (r.loggerName.isEmpty) {
loggerOnDataCallback()?.call(r);
}
});
}

Future<void> _initFirebase() async {
Expand Down
1 change: 1 addition & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:logging/logging.dart';

import 'app.dart';
import 'core/infrastructure/local/shared_preferences_facade.dart';
import 'core/infrastructure/services/logger.dart';
import 'core/presentation/extensions/future_extensions.dart';
import 'core/presentation/providers/device_info_providers.dart';
import 'core/presentation/providers/provider_observers.dart';
Expand Down

0 comments on commit 514ebdb

Please sign in to comment.