logging framework

This commit is contained in:
austinried
2025-12-14 10:09:32 +09:00
parent 7f6ba4776a
commit 2837d4576e
8 changed files with 223 additions and 42 deletions

View File

@@ -7,6 +7,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
import '../../database/dao/sources_dao.dart';
import '../../database/database.dart';
import '../../l10n/generated/app_localizations.dart';
import '../../util/logger.dart';
import '../state/database.dart';
import '../util/padding.dart';
@@ -216,6 +217,7 @@ class _SettingsSourceScreen extends HookConsumerWidget {
} catch (e, _) {
// showErrorSnackbar(context, e.toString());
// log.severe('Saving source', e, st);
logger.w('fuck');
error = true;
} finally {
isSaving.value = false;

View File

@@ -6,44 +6,40 @@ import '../../database/database.dart';
final databaseInitializer = FutureProvider<SubtracksDatabase>((ref) async {
final db = SubtracksDatabase();
await db
.batch((batch) {
batch.insertAll(
db.sources,
[
SourcesCompanion.insert(
id: Value(1),
name: 'test subsonic',
isActive: Value(true),
),
SourcesCompanion.insert(
id: Value(2),
name: 'test navidrome',
isActive: Value(null),
),
],
mode: InsertMode.insertOrIgnore,
);
batch.insertAllOnConflictUpdate(db.subsonicSettings, [
SubsonicSettingsCompanion.insert(
sourceId: Value(1),
address: Uri.parse('http://demo.subsonic.org'),
username: 'guest1',
password: 'guest',
useTokenAuth: Value(true),
),
SubsonicSettingsCompanion.insert(
sourceId: Value(2),
address: Uri.parse('http://10.0.2.2:4533'),
username: 'admin',
password: 'password',
useTokenAuth: Value(true),
),
]);
})
.onError((error, stack) {
print(error);
});
await db.batch((batch) {
batch.insertAll(
db.sources,
[
SourcesCompanion.insert(
id: Value(1),
name: 'test subsonic',
isActive: Value(true),
),
SourcesCompanion.insert(
id: Value(2),
name: 'test navidrome',
isActive: Value(null),
),
],
mode: InsertMode.insertOrIgnore,
);
batch.insertAllOnConflictUpdate(db.subsonicSettings, [
SubsonicSettingsCompanion.insert(
sourceId: Value(1),
address: Uri.parse('http://demo.subsonic.org'),
username: 'guest1',
password: 'guest',
useTokenAuth: Value(true),
),
SubsonicSettingsCompanion.insert(
sourceId: Value(2),
address: Uri.parse('http://10.0.2.2:4533'),
username: 'admin',
password: 'password',
useTokenAuth: Value(true),
),
]);
});
return db;
});

View File

@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import '../../util/logger.dart';
import '../state/source.dart';
import '../util/color_scheme.dart';
import 'theme.dart';
@@ -36,8 +37,12 @@ class CoverArtTheme extends HookConsumerWidget {
: 'https://placehold.net/400x400.png',
),
);
} catch (err) {
print(err);
} catch (error, stackTrace) {
logger.w(
'Could not create color scheme from image provider',
error: error,
stackTrace: stackTrace,
);
return null;
}
},