Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add severe log for error cases of all loaders #2023

Merged
merged 19 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/lib/common/actions/close_room.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:acter/common/providers/sdk_provider.dart';
import 'package:acter/common/providers/space_providers.dart';
import 'package:acter/common/toolkit/buttons/danger_action_button.dart';
import 'package:acter/common/utils/routes.dart';

import 'package:acter/common/widgets/room/room_profile_header.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
Expand Down
1 change: 0 additions & 1 deletion app/lib/common/actions/report_content.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:acter/common/providers/chat_providers.dart';
import 'package:acter/common/providers/room_providers.dart';
import 'package:acter/common/providers/space_providers.dart';

import 'package:acter/common/toolkit/buttons/primary_action_button.dart';
import 'package:acter/common/widgets/default_dialog.dart';
import 'package:acter/common/widgets/input_text_field.dart';
Expand Down
2 changes: 1 addition & 1 deletion app/lib/common/providers/common_providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:flutter/material.dart';
import 'package:logging/logging.dart';
import 'package:riverpod/riverpod.dart';

final _log = Logger('a3::common::providers');
final _log = Logger('a3::common::common_providers');

// Loading Providers
final loadingProvider = StateProvider<bool>((ref) => false);
Expand Down
2 changes: 1 addition & 1 deletion app/lib/common/providers/notifiers/chat_notifiers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:flutter/widgets.dart';
import 'package:logging/logging.dart';
import 'package:riverpod/riverpod.dart';

final _log = Logger('a3::common::chat');
final _log = Logger('a3::common::chat_notifiers');

class AsyncConvoNotifier extends FamilyAsyncNotifier<Convo?, String> {
late Stream<bool> _listener;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:acter_flutter_sdk/acter_flutter_sdk_ffi.dart';
import 'package:logging/logging.dart';
import 'package:riverpod/riverpod.dart';

final _log = Logger('a3::common::notification_settings');
final _log = Logger('a3::common::notification_settings_notifier');

class AsyncNotificationSettingsNotifier
extends AsyncNotifier<NotificationSettings> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:acter_flutter_sdk/acter_flutter_sdk_ffi.dart';
import 'package:logging/logging.dart';
import 'package:riverpod/riverpod.dart';

final _log = Logger('a3::common::reactions');
final _log = Logger('a3::common::reactions_notifiers');

class ReactionManagerNotifier
extends FamilyNotifier<ReactionManager, ReactionManager> {
Expand Down
4 changes: 2 additions & 2 deletions app/lib/common/providers/notifiers/room_notifiers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import 'package:acter/features/home/providers/client_providers.dart';
import 'package:acter_avatar/acter_avatar.dart';
import 'package:acter_flutter_sdk/acter_flutter_sdk_ffi.dart';
import 'package:flutter/material.dart';
import 'package:riverpod/riverpod.dart';
import 'package:logging/logging.dart';
import 'package:riverpod/riverpod.dart';

final _log = Logger('a3::common::room');
final _log = Logger('a3::common::room_notifiers');

class AsyncMaybeRoomNotifier extends FamilyAsyncNotifier<Room?, String> {
late Stream<bool> _listener;
Expand Down
4 changes: 2 additions & 2 deletions app/lib/common/providers/notifiers/space_notifiers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import 'dart:async';

import 'package:acter/features/home/providers/client_providers.dart';
import 'package:acter_flutter_sdk/acter_flutter_sdk_ffi.dart';
import 'package:riverpod/riverpod.dart';
import 'package:logging/logging.dart';
import 'package:riverpod/riverpod.dart';

final _log = Logger('a3::common::space');
final _log = Logger('a3::common::space_notifiers');

class AsyncMaybeSpaceNotifier extends FamilyAsyncNotifier<Space?, String> {
late Stream<bool> _listener;
Expand Down
3 changes: 2 additions & 1 deletion app/lib/common/utils/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import 'dart:async';
import 'dart:convert';
import 'dart:math';

import 'package:acter/common/providers/room_providers.dart';
import 'package:acter/common/utils/routes.dart';
import 'package:acter_flutter_sdk/acter_flutter_sdk.dart';
Expand All @@ -13,9 +14,9 @@ import 'package:flutter_chat_types/flutter_chat_types.dart' as types;
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:intl/intl.dart';
import 'package:jiffy/jiffy.dart';
import 'package:go_router/go_router.dart';
import 'package:logging/logging.dart';
import 'package:url_launcher/url_launcher.dart';

Expand Down
4 changes: 2 additions & 2 deletions app/lib/common/widgets/chat/edit_room_description_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import 'package:acter/common/providers/room_providers.dart';
import 'package:acter/common/toolkit/buttons/primary_action_button.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:logging/logging.dart';

final _log = Logger('a3::chat::room_description_edit_sheet');
final _log = Logger('a3::common::chat::room_description');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you elaborate why you are changing all these log targets and what pattern you are using? I was thinking it was just the files names but this one is clearly different ... how is it meant to be understood?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just wanted for developer to guess file path from logger name.
So renamed many loggers according to their file path.


void showEditRoomDescriptionBottomSheet({
required BuildContext context,
Expand Down
30 changes: 17 additions & 13 deletions app/lib/common/widgets/event/event_selector_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import 'package:acter/features/events/widgets/event_item.dart';
import 'package:acter/features/events/widgets/skeletons/event_list_skeleton_widget.dart';
import 'package:atlas_icons/atlas_icons.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:logging/logging.dart';

final _log = Logger('a3::common::cal_event::select_drawer');

const Key selectEventDrawerKey = Key('event-widgets-select-event-drawer');

Expand Down Expand Up @@ -56,28 +60,28 @@ Future<String?> selectEventDrawer({
: ListView.builder(
padding: const EdgeInsets.all(8),
itemCount: eventsList.length,
itemBuilder: (context, index) {
final event = eventsList[index];
return EventItem(
event: event,
isShowRsvp: false,
onTapEventItem: (event) {
Navigator.pop(context, event);
},
);
},
itemBuilder: (context, index) => EventItem(
event: eventsList[index],
isShowRsvp: false,
onTapEventItem: (event) {
Navigator.pop(context, event);
},
),
),
),
],
);
},
error: (error, stack) {
_log.severe('Failed to load all cal events', error, stack);
return Center(
child: Text('Failed to load: $error'),
child: Text(L10n.of(context).failedToLoadEventsDueTo(error)),
);
},
loading: () =>
const SizedBox(height: 500, child: EventListSkeleton()),
loading: () => const SizedBox(
height: 500,
child: EventListSkeleton(),
),
);
},
),
Expand Down
17 changes: 12 additions & 5 deletions app/lib/common/widgets/room/select_room_drawer.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import 'package:acter/common/providers/chat_providers.dart';
import 'package:acter/common/providers/room_providers.dart';
import 'package:acter/common/providers/space_providers.dart';

import 'package:acter/common/widgets/room/brief_room_list_entry.dart';
import 'package:acter_avatar/acter_avatar.dart';
import 'package:atlas_icons/atlas_icons.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:logging/logging.dart';
import 'package:path/path.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';

final _log = Logger('a3::common::room::select_drawer');

// ChildRoomType configures the sub child type of the `Spaces`
enum RoomType {
Expand Down Expand Up @@ -143,14 +145,14 @@ class _SelectRoomDrawerState extends ConsumerState<SelectRoomDrawer> {

//Show space list based on the search term
Widget searchedRoomsList(BuildContext context) {
final searchedrooms = ref.watch(
final searched = ref.watch(
switch (widget.roomType) {
RoomType.space => searchedSpacesProvider,
RoomType.groupChat => roomSearchedChatsProvider,
},
);

return searchedrooms.when(
return searched.when(
data: (rooms) {
if (rooms.isEmpty) {
return Center(
Expand All @@ -164,7 +166,12 @@ class _SelectRoomDrawerState extends ConsumerState<SelectRoomDrawer> {
heightFactor: 10,
child: CircularProgressIndicator(),
),
error: (e, s) => Center(child: Text(L10n.of(context).searchingFailed(e))),
error: (e, s) {
_log.severe('Failed to search space or convo', e, s);
return Center(
child: Text(L10n.of(context).searchingFailed(e)),
);
},
);
}

Expand Down
8 changes: 7 additions & 1 deletion app/lib/common/widgets/spaces/has_space_permission.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import 'package:acter/common/providers/room_providers.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:logging/logging.dart';

final _log = Logger('a3::common::spaces::has_permission');

class HasSpacePermission extends ConsumerWidget {
final String spaceId;
Expand All @@ -22,7 +25,10 @@ class HasSpacePermission extends ConsumerWidget {
return ref.watch(roomMembershipProvider(spaceId)).when(
data: (membership) =>
membership?.canString(permission) == true ? child : otherwise,
error: (e, s) => otherwise,
error: (e, s) {
_log.severe('Failed to load membership', e, s);
return otherwise;
},
loading: () => otherwise,
);
}
Expand Down
8 changes: 7 additions & 1 deletion app/lib/common/widgets/spaces/select_space_form_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import 'package:acter_avatar/acter_avatar.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:logging/logging.dart';
import 'package:skeletonizer/skeletonizer.dart';

final _log = Logger('a3::common::spaces::select_form_field');

class SelectSpaceFormField extends ConsumerWidget {
static Key openKey = const Key('select-space-form-field-open');

Expand Down Expand Up @@ -103,7 +106,10 @@ class SelectSpaceFormField extends ConsumerWidget {
useCompatView ? selectSpace(context, ref) : null,
)
: Text(currentSelectedSpace!),
error: (e, s) => Text(L10n.of(context).errorLoading(e)),
error: (e, s) {
_log.severe('Failed to load the details of selected space', e, s);
return Text(L10n.of(context).loadingFailed(e));
},
loading: () => Skeletonizer(
child: Chip(
avatar: ActerAvatar(
Expand Down
10 changes: 8 additions & 2 deletions app/lib/common/widgets/spaces/space_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ import 'package:acter/common/widgets/visibility/visibility_chip.dart';
import 'package:acter_flutter_sdk/acter_flutter_sdk_ffi.dart';
import 'package:atlas_icons/atlas_icons.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:logging/logging.dart';
import 'package:skeletonizer/skeletonizer.dart';

final _log = Logger('a3::common::spaces::info');

final isActerSpaceForSpace =
FutureProvider.autoDispose.family<bool, Space>((ref, space) async {
return await space.isActerSpace();
Expand All @@ -33,7 +36,10 @@ class SpaceInfo extends ConsumerWidget {
],
);
},
error: (e, s) => Text(L10n.of(context).error(e)),
error: (e, s) {
_log.severe('Failed to load space', e, s);
return Text(L10n.of(context).loadingFailed(e));
},
loading: () => skeletonUI(),
);
}
Expand Down
5 changes: 2 additions & 3 deletions app/lib/common/widgets/user_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ import 'dart:typed_data';

import 'package:acter/common/providers/room_providers.dart';
import 'package:acter/common/themes/colors/color_scheme.dart';

import 'package:acter_avatar/acter_avatar.dart';
import 'package:acter_flutter_sdk/acter_flutter_sdk_ffi.dart';
import 'package:atlas_icons/atlas_icons.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:skeletonizer/skeletonizer.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:logging/logging.dart';
import 'package:skeletonizer/skeletonizer.dart';

final _log = Logger('a3::common::user');

Expand Down
14 changes: 10 additions & 4 deletions app/lib/common/widgets/visibility/visibility_chip.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ import 'package:acter/common/providers/room_providers.dart';
import 'package:acter/common/utils/utils.dart';
import 'package:atlas_icons/atlas_icons.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:logging/logging.dart';
import 'package:skeletonizer/skeletonizer.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';

final _log = Logger('a3::common::visibility::chip');

class VisibilityChip extends ConsumerWidget {
final String roomId;
Expand All @@ -18,9 +21,12 @@ class VisibilityChip extends ConsumerWidget {
data: (visibility) {
return renderSpaceChip(context, visibility);
},
error: (error, st) => Chip(
label: Text(L10n.of(context).loadingFailed(error)),
),
error: (error, st) {
_log.severe('Failed to load room visibility', error, st);
return Chip(
label: Text(L10n.of(context).loadingFailed(error)),
);
},
loading: () => renderLoading(),
);
}
Expand Down
1 change: 0 additions & 1 deletion app/lib/features/activities/widgets/invitation_card.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:acter/common/providers/room_providers.dart';

import 'package:acter/common/toolkit/buttons/primary_action_button.dart';
import 'package:acter/features/activities/providers/invitations_providers.dart';
import 'package:acter/features/home/providers/client_providers.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:logging/logging.dart';
import 'package:path_provider/path_provider.dart';
import 'package:riverpod/riverpod.dart';

final _log = Logger('a3::common::attachments');
final _log = Logger('a3::attachments::notifiers');

class AttachmentsManagerNotifier extends AutoDisposeFamilyAsyncNotifier<
AttachmentsManager, Future<AttachmentsManager>> {
Expand Down
13 changes: 11 additions & 2 deletions app/lib/features/attachments/widgets/attachment_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ import 'package:atlas_icons/atlas_icons.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:logging/logging.dart';
import 'package:skeletonizer/skeletonizer.dart';

final _log = Logger('a3::attachments::section');

class AttachmentSectionWidget extends ConsumerWidget {
static const attachmentsKey = Key('attachments');
static const redactBtnKey = Key('attachments-redact-btn');
Expand All @@ -30,7 +33,10 @@ class AttachmentSectionWidget extends ConsumerWidget {
attachmentManager: manager,
key: attachmentsKey,
),
error: (e, st) => onError(context, e),
error: (e, st) {
_log.severe('Failed to load attachment manager', e, st);
return onError(context, e);
},
loading: () => loading(context),
);
}
Expand Down Expand Up @@ -69,7 +75,10 @@ class FoundAttachmentSectionWidget extends ConsumerWidget {

return attachments.when(
data: (list) => attachmentData(list, context, ref),
error: (err, st) => Text(L10n.of(context).errorLoadingAttachments(err)),
error: (err, st) {
_log.severe('Failed to load attachments', err, st);
return Text(L10n.of(context).errorLoadingAttachments(err));
},
loading: () => const Skeletonizer(
child: Wrap(
spacing: 5.0,
Expand Down
2 changes: 1 addition & 1 deletion app/lib/features/auth/pages/forgot_password.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'package:flutter_svg/flutter_svg.dart';
import 'package:go_router/go_router.dart';
import 'package:logging/logging.dart';

final _log = Logger('a3::auth::passwordReset');
final _log = Logger('a3::auth::forgot_password');

class ForgotPassword extends ConsumerStatefulWidget {
static Key passwordKey = const Key('pw-reset-password-field');
Expand Down
Loading
Loading