Merge pull request #214 from cogwheel0/refactor-remove-verbose-logging

refactor(logging): Remove verbose debug logging across multiple services
This commit is contained in:
cogwheel
2025-12-03 14:08:48 +05:30
committed by GitHub
4 changed files with 1 additions and 125 deletions

View File

@@ -85,10 +85,6 @@ class ApiAuthInterceptor extends Interceptor {
final requiresAuth = _requiresAuth(path);
final hasOptionalAuth = _hasOptionalAuth(path);
DebugLogger.auth(
'Auth interceptor for $path - requires: $requiresAuth, optional: $hasOptionalAuth, token present: ${_authToken != null}',
);
if (requiresAuth) {
// Strictly required authentication
if (_authToken == null || _authToken!.isEmpty) {

View File

@@ -675,7 +675,6 @@ class Models extends _$Models {
});
return cached;
}
DebugLogger.log('cache-empty', scope: 'models/cache');
} catch (error, stackTrace) {
DebugLogger.error(
'cache-load-failed',
@@ -1012,14 +1011,8 @@ class Conversations extends _$Conversations {
);
}
});
DebugLogger.log(
'cache-restored',
scope: 'conversations/cache',
data: {'count': sortedCached.length},
);
return sortedCached;
}
DebugLogger.log('cache-empty', scope: 'conversations/cache');
} catch (error, stackTrace) {
DebugLogger.error(
'cache-load-failed',
@@ -1125,11 +1118,6 @@ class Conversations extends _$Conversations {
Future<void>(() async {
try {
await storage.saveLocalConversations(conversations);
DebugLogger.log(
'cache-saved',
scope: 'conversations/cache',
data: {'count': conversations.length},
);
} catch (error, stackTrace) {
DebugLogger.error(
'cache-save-failed',
@@ -1205,22 +1193,8 @@ class Conversations extends _$Conversations {
final conversationToFolder = <String, String>{};
for (final folder in folders) {
DebugLogger.log(
'folder',
scope: 'conversations/map',
data: {
'id': folder.id,
'name': folder.name,
'count': folder.conversationIds.length,
},
);
for (final conversationId in folder.conversationIds) {
conversationToFolder[conversationId] = folder.id;
DebugLogger.log(
'map',
scope: 'conversations/map',
data: {'conversationId': conversationId, 'folderId': folder.id},
);
}
}
@@ -1234,15 +1208,6 @@ class Conversations extends _$Conversations {
conversationMap[conversation.id] = conversation.copyWith(
folderId: folderIdToUse,
);
DebugLogger.log(
'update-folder',
scope: 'conversations/map',
data: {
'conversationId': conversation.id,
'folderId': folderIdToUse,
'explicit': explicitFolderId != null,
},
);
} else {
conversationMap[conversation.id] = conversation;
}
@@ -1261,8 +1226,6 @@ class Conversations extends _$Conversations {
'preview': missingInBase.take(5).toList(),
},
);
} else {
DebugLogger.log('folders-synced', scope: 'conversations/map');
}
for (final folder in folders) {
@@ -1311,11 +1274,6 @@ class Conversations extends _$Conversations {
: fetched;
conversationMap[toAdd.id] = toAdd;
existingIds.add(toAdd.id);
DebugLogger.log(
'add-missing',
scope: 'conversations/map',
data: {'conversationId': toAdd.id, 'folderId': folder.id},
);
} else {
final placeholder = Conversation(
id: convId,
@@ -1327,11 +1285,6 @@ class Conversations extends _$Conversations {
);
conversationMap[convId] = placeholder;
existingIds.add(convId);
DebugLogger.log(
'add-placeholder',
scope: 'conversations/map',
data: {'conversationId': convId, 'folderId': folder.id},
);
}
}
@@ -1342,11 +1295,6 @@ class Conversations extends _$Conversations {
: conv;
conversationMap[toAdd.id] = toAdd;
existingIds.add(toAdd.id);
DebugLogger.log(
'add-folder-fetch',
scope: 'conversations/map',
data: {'conversationId': toAdd.id, 'folderId': folder.id},
);
}
}
}
@@ -1354,11 +1302,6 @@ class Conversations extends _$Conversations {
final sortedConversations = _sortByUpdatedAt(
conversationMap.values.toList(),
);
DebugLogger.log(
'sort',
scope: 'conversations',
data: {'source': 'folder-sync'},
);
_updateCacheTimestamp(DateTime.now());
return sortedConversations;
} catch (e, stackTrace) {
@@ -2083,11 +2026,6 @@ class Folders extends _$Folders {
final storage = ref.watch(optimizedStorageServiceProvider);
final cached = await storage.getLocalFolders();
if (cached.isNotEmpty) {
DebugLogger.log(
'cache-restored',
scope: 'folders/cache',
data: {'count': cached.length},
);
Future.microtask(() async {
try {
await refresh();
@@ -2103,7 +2041,6 @@ class Folders extends _$Folders {
return _sort(cached);
}
DebugLogger.log('cache-empty', scope: 'folders/cache');
final api = ref.watch(apiServiceProvider);
if (api == null) {
DebugLogger.warning('api-missing', scope: 'folders');

View File

@@ -344,10 +344,6 @@ class OptimizedStorageService {
'items': jsonReady,
}, debugLabel: 'encode_local_conversations');
await _cachesBox.put(_localConversationsKey, serialized);
DebugLogger.log(
'Saved ${conversations.length} local conversations',
scope: 'storage/optimized',
);
} catch (error, stack) {
DebugLogger.error(
'Failed to save local conversations',
@@ -390,10 +386,6 @@ class OptimizedStorageService {
'items': jsonReady,
}, debugLabel: 'encode_local_folders');
await _cachesBox.put(_localFoldersKey, serialized);
DebugLogger.log(
'Saved ${folders.length} local folders',
scope: 'storage/optimized',
);
} catch (error, stack) {
DebugLogger.error(
'Failed to save local folders',
@@ -436,7 +428,6 @@ class OptimizedStorageService {
}
final serialized = jsonEncode(user.toJson());
await _cachesBox.put(_localUserKey, serialized);
DebugLogger.log('Saved local user profile', scope: 'storage/optimized');
} catch (error, stack) {
DebugLogger.error(
'Failed to save local user',
@@ -649,10 +640,6 @@ class OptimizedStorageService {
'items': jsonReady,
}, debugLabel: 'encode_local_models');
await _cachesBox.put(_localModelsKey, _wrapServerScoped(serialized));
DebugLogger.log(
'Saved ${models.length} local models',
scope: 'storage/optimized',
);
} catch (error, stack) {
DebugLogger.error(
'Failed to save local models',
@@ -699,10 +686,6 @@ class OptimizedStorageService {
'items': jsonReady,
}, debugLabel: 'encode_local_tools');
await _cachesBox.put(_localToolsKey, _wrapServerScoped(serialized));
DebugLogger.log(
'Saved ${tools.length} local tools',
scope: 'storage/optimized',
);
} catch (error, stack) {
DebugLogger.error(
'Failed to save local tools',

View File

@@ -19,13 +19,7 @@ typedef WorkerTask<Q, R> = ComputeCallback<Q, R>;
/// synchronously because secondary isolates are not supported.
class WorkerManager {
WorkerManager({int maxConcurrentTasks = _defaultMaxConcurrentTasks})
: _maxConcurrentTasks = math.max(1, maxConcurrentTasks) {
DebugLogger.log(
'initialized',
scope: 'worker',
data: {'max': _maxConcurrentTasks},
);
}
: _maxConcurrentTasks = math.max(1, maxConcurrentTasks);
static const int _defaultMaxConcurrentTasks = 2;
@@ -73,18 +67,6 @@ class WorkerManager {
);
_pendingJobs.add(job);
DebugLogger.log(
'queued',
scope: 'worker',
data: {
'id': jobId,
if (debugLabel != null) 'label': debugLabel,
'pending': _pendingJobs.length,
'active': _activeJobs,
},
);
_processQueue();
return completer.future;
@@ -104,7 +86,6 @@ class WorkerManager {
);
}
DebugLogger.log('disposed', scope: 'worker', data: {'active': _activeJobs});
}
void _processQueue() {
@@ -120,17 +101,6 @@ class WorkerManager {
void _startJob(_EnqueuedJob job) {
_activeJobs++;
DebugLogger.log(
'started',
scope: 'worker',
data: {
'id': job.id,
if (job.debugLabel != null) 'label': job.debugLabel,
'active': _activeJobs,
},
);
unawaited(_runJob(job));
}
@@ -138,16 +108,6 @@ class WorkerManager {
try {
final result = await job.run();
job.onComplete(result);
DebugLogger.log(
'completed',
scope: 'worker',
data: {
'id': job.id,
if (job.debugLabel != null) 'label': job.debugLabel,
'pending': _pendingJobs.length,
},
);
} catch (error, stackTrace) {
job.onError(error, stackTrace);