1
0
mirror of https://github.com/immich-app/immich.git synced 2025-07-16 07:24:40 +02:00

feature(mobile): configurable log level (#2248)

* feature(mobile): configurable log level

* increase maxLogEntries to 500

---------

Co-authored-by: Fynn Petersen-Frey <zoodyy@users.noreply.github.com>
This commit is contained in:
Fynn Petersen-Frey
2023-04-14 15:50:46 +02:00
committed by GitHub
parent 4952b3a2d6
commit d500ef77cf
6 changed files with 73 additions and 17 deletions

View File

@ -43,17 +43,14 @@ enum AppSettingsEnum<T> {
"selectedAlbumSortOrder",
0,
),
advancedTroubleshooting<bool>(
StoreKey.advancedTroubleshooting,
"advancedTroubleshooting",
false,
),
advancedTroubleshooting<bool>(StoreKey.advancedTroubleshooting, null, false),
logLevel<int>(StoreKey.logLevel, null, 5) // Level.INFO = 5
;
const AppSettingsEnum(this.storeKey, this.hiveKey, this.defaultValue);
final StoreKey<T> storeKey;
final String hiveKey;
final String? hiveKey;
final T defaultValue;
}

View File

@ -5,6 +5,8 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/modules/settings/providers/app_settings.provider.dart';
import 'package:immich_mobile/modules/settings/services/app_settings.service.dart';
import 'package:immich_mobile/modules/settings/ui/settings_switch_list_tile.dart';
import 'package:immich_mobile/shared/services/immich_logger.service.dart';
import 'package:logging/logging.dart';
class AdvancedSettings extends HookConsumerWidget {
const AdvancedSettings({super.key});
@ -13,16 +15,21 @@ class AdvancedSettings extends HookConsumerWidget {
final appSettingService = ref.watch(appSettingsServiceProvider);
final isEnabled =
useState(AppSettingsEnum.advancedTroubleshooting.defaultValue);
final levelId = useState(AppSettingsEnum.logLevel.defaultValue);
useEffect(
() {
isEnabled.value = appSettingService.getSetting<bool>(
AppSettingsEnum.advancedTroubleshooting,
);
levelId.value = appSettingService.getSetting(AppSettingsEnum.logLevel);
return null;
},
[],
);
final logLevel = Level.LEVELS[levelId.value].name;
return ExpansionTile(
textColor: Theme.of(context).primaryColor,
title: const Text(
@ -46,6 +53,30 @@ class AdvancedSettings extends HookConsumerWidget {
title: "advanced_settings_troubleshooting_title".tr(),
subtitle: "advanced_settings_troubleshooting_subtitle".tr(),
),
ListTile(
dense: true,
title: Text(
// Not translated because the levels are only English
"Log level: $logLevel",
style: const TextStyle(fontWeight: FontWeight.bold),
),
subtitle: Slider(
value: levelId.value.toDouble(),
onChanged: (double v) => levelId.value = v.toInt(),
onChangeEnd: (double v) {
appSettingService.setSetting(
AppSettingsEnum.logLevel,
v.toInt(),
);
ImmichLogger().level = Level.LEVELS[v.toInt()];
},
max: 8,
min: 1.0,
divisions: 7,
label: logLevel,
activeColor: Theme.of(context).primaryColor,
),
),
],
);
}