Enchance logs for easier debugging

This commit is contained in:
Neeraj Gupta 2022-11-11 15:53:35 +05:30
parent 2fa1c19d0c
commit 4cc2f70710
No known key found for this signature in database
GPG key ID: 3C5A1684DC1729E1
8 changed files with 19 additions and 14 deletions

View file

@ -1,7 +1,12 @@
import 'package:photos/events/event.dart';
class ForceReloadHomeGalleryEvent extends Event {
ForceReloadHomeGalleryEvent();
final String message;
ForceReloadHomeGalleryEvent(this.message);
@override
String toString() {
return 'ForceReloadHomeGalleryEvent{message: $message}';
}
}

View file

@ -755,7 +755,7 @@ class CollectionsService {
await _filesDB.deleteUnSyncedLocalFiles(localIDs);
}
// Force reload home gallery to pull in the restored files
Bus.instance.fire(ForceReloadHomeGalleryEvent());
Bus.instance.fire(ForceReloadHomeGalleryEvent("restoredFromTrash"));
} catch (e, s) {
_logger.severe("failed to restore files", e, s);
rethrow;

View file

@ -36,7 +36,7 @@ class FileMagicService {
await _updateMagicData(files, update);
if (visibility == visibilityVisible) {
// Force reload home gallery to pull in the now unarchived files
Bus.instance.fire(ForceReloadHomeGalleryEvent());
Bus.instance.fire(ForceReloadHomeGalleryEvent("unarchivedFiles"));
Bus.instance
.fire(LocalPhotosUpdatedEvent(files, type: EventType.unarchived));
} else {

View file

@ -75,7 +75,7 @@ extension HiddenService on CollectionsService {
}
await move(defaultHiddenCollection.id, entry.key, entry.value);
}
Bus.instance.fire(ForceReloadHomeGalleryEvent());
Bus.instance.fire(ForceReloadHomeGalleryEvent("hideFiles"));
Bus.instance.fire(
LocalPhotosUpdatedEvent(filesToHide, type: EventType.unarchived),
);

View file

@ -325,8 +325,8 @@ class RemoteSyncService {
}
}
if (moreFilesMarkedForBackup && !_config.hasSelectedAllFoldersForBackup()) {
debugPrint("force reload due to display new files");
Bus.instance.fire(ForceReloadHomeGalleryEvent());
// "force reload due to display new files"
Bus.instance.fire(ForceReloadHomeGalleryEvent("newFilesDisplay"));
}
}
@ -688,8 +688,8 @@ class RemoteSyncService {
" remoteFiles seen first time",
);
if (needsGalleryReload) {
_logger.fine('force reload home gallery');
Bus.instance.fire(ForceReloadHomeGalleryEvent());
// 'force reload home gallery'
Bus.instance.fire(ForceReloadHomeGalleryEvent("remoteSync"));
}
}

View file

@ -98,7 +98,7 @@ class _LazyLoadingGalleryState extends State<LazyLoadingGallery> {
if (kDebugMode) {
_logger.info(
filesUpdatedThisDay.length.toString() +
" files were updated due to ${event.type} on " +
" files were updated due to ${event.type.name} on " +
getDayTitle(galleryDate.microsecondsSinceEpoch),
);
}

View file

@ -109,7 +109,7 @@ class _GalleryState extends State<Gallery> {
for (final event in widget.forceReloadEvents) {
_forceReloadEventSubscriptions.add(
event.listen((event) async {
_logger.info("Force reload triggered");
_logger.info("Force reload $event");
final result = await _loadFiles();
_setFilesAndReload(result.files);
}),

View file

@ -61,7 +61,7 @@ Future<void> changeCollectionVisibility(
final Map<String, dynamic> update = {magicKeyVisibility: newVisibility};
await CollectionsService.instance.updateMagicMetadata(collection, update);
// Force reload home gallery to pull in the now unarchived files
Bus.instance.fire(ForceReloadHomeGalleryEvent());
Bus.instance.fire(ForceReloadHomeGalleryEvent("CollectionArchiveChange"));
showShortToast(
context,
newVisibility == visibilityArchive
@ -177,7 +177,7 @@ Future<void> _updatePublicMetadata(
}
if (_shouldReloadGallery(key)) {
Bus.instance.fire(ForceReloadHomeGalleryEvent());
Bus.instance.fire(ForceReloadHomeGalleryEvent("FileMetadataChange-$key"));
}
} catch (e, s) {
_logger.severe("failed to update $key = $value", e, s);