Skip to content

Conversation

simolus3
Copy link
Contributor

When we use a worker for the streaming sync implementation, we currently have an independent autoLogger for that. This makes it impossible for users to customize or disable the logs emitted by the worker.

By re-using the logger from the PowerSyncDatabase instead, users can customize the log levels. Closes #225.

Unfortunately this is hard to test without setting up integration tests as it requires the worker. The fix can be verified manually by applying the snippet suggested in #225 in an example project:

diff --git a/demos/supabase-todolist/lib/powersync.dart b/demos/supabase-todolist/lib/powersync.dart
index 166de1b..4e1cbf1 100644
--- a/demos/supabase-todolist/lib/powersync.dart
+++ b/demos/supabase-todolist/lib/powersync.dart
@@ -155,8 +155,13 @@ Future<String> getDatabasePath() async {
 
 Future<void> openDatabase() async {
   // Open the local database
+  hierarchicalLoggingEnabled = true;
+  final logger = Logger('PowerSyncLogger')..level = Level.OFF;
   db = PowerSyncDatabase(
-      schema: schema, path: await getDatabasePath(), logger: attachedLogger);
+    schema: schema,
+    path: await getDatabasePath(),
+    logger: logger,
+  );
   await db.initialize();
 
   await loadSupabase();

@simolus3 simolus3 merged commit 05e0526 into main Jan 27, 2025
4 checks passed
@simolus3 simolus3 deleted the fix/sync-worker-logs branch January 27, 2025 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Impossible to disable debug logging for web builds

2 participants