mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2024-12-25 07:39:25 -05:00
cleanup
This commit is contained in:
parent
9dd17cb077
commit
a551791f97
1
devtools_options.yaml
Normal file
1
devtools_options.yaml
Normal file
@ -0,0 +1 @@
|
|||||||
|
extensions:
|
@ -10,6 +10,7 @@ import 'account_manager/account_manager.dart';
|
|||||||
import 'router/router.dart';
|
import 'router/router.dart';
|
||||||
import 'settings/settings.dart';
|
import 'settings/settings.dart';
|
||||||
import 'tick.dart';
|
import 'tick.dart';
|
||||||
|
import 'veilid_processor/veilid_processor.dart';
|
||||||
|
|
||||||
class VeilidChatApp extends StatelessWidget {
|
class VeilidChatApp extends StatelessWidget {
|
||||||
const VeilidChatApp({
|
const VeilidChatApp({
|
||||||
@ -31,6 +32,9 @@ class VeilidChatApp extends StatelessWidget {
|
|||||||
state: LocalizationProvider.of(context).state,
|
state: LocalizationProvider.of(context).state,
|
||||||
child: MultiBlocProvider(
|
child: MultiBlocProvider(
|
||||||
providers: [
|
providers: [
|
||||||
|
BlocProvider<ConnectionStateCubit>(
|
||||||
|
create: (context) =>
|
||||||
|
ConnectionStateCubit(ProcessorRepository.instance)),
|
||||||
BlocProvider<RouterCubit>(
|
BlocProvider<RouterCubit>(
|
||||||
create: (context) =>
|
create: (context) =>
|
||||||
RouterCubit(AccountRepository.instance),
|
RouterCubit(AccountRepository.instance),
|
||||||
|
@ -19,11 +19,11 @@ Future<void> initializeVeilid() async {
|
|||||||
// Veilid logging
|
// Veilid logging
|
||||||
initVeilidLog(kDebugMode);
|
initVeilidLog(kDebugMode);
|
||||||
|
|
||||||
// DHT Record Pool
|
|
||||||
await DHTRecordPool.init();
|
|
||||||
|
|
||||||
// Startup Veilid
|
// Startup Veilid
|
||||||
await ProcessorRepository.instance.startup();
|
await ProcessorRepository.instance.startup();
|
||||||
|
|
||||||
|
// DHT Record Pool
|
||||||
|
await DHTRecordPool.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize repositories
|
// Initialize repositories
|
||||||
|
@ -1,33 +1,60 @@
|
|||||||
import 'package:bloc/bloc.dart';
|
import 'package:bloc/bloc.dart';
|
||||||
|
import 'package:loggy/loggy.dart';
|
||||||
import 'loggy.dart';
|
import 'loggy.dart';
|
||||||
|
|
||||||
|
const Map<String, LogLevel> _blocChangeLogLevels = {
|
||||||
|
'ConnectionStateCubit': LogLevel.off
|
||||||
|
};
|
||||||
|
const Map<String, LogLevel> _blocCreateCloseLogLevels = {};
|
||||||
|
const Map<String, LogLevel> _blocErrorLogLevels = {};
|
||||||
|
|
||||||
/// [BlocObserver] for the VeilidChat application that
|
/// [BlocObserver] for the VeilidChat application that
|
||||||
/// observes all state changes.
|
/// observes all state changes.
|
||||||
class StateLogger extends BlocObserver {
|
class StateLogger extends BlocObserver {
|
||||||
/// {@macro counter_observer}
|
/// {@macro counter_observer}
|
||||||
const StateLogger();
|
const StateLogger();
|
||||||
|
|
||||||
|
void _checkLogLevel(
|
||||||
|
Map<String, LogLevel> blocLogLevels,
|
||||||
|
LogLevel defaultLogLevel,
|
||||||
|
BlocBase<dynamic> bloc,
|
||||||
|
void Function(LogLevel) closure) {
|
||||||
|
final logLevel =
|
||||||
|
blocLogLevels[bloc.runtimeType.toString()] ?? defaultLogLevel;
|
||||||
|
if (logLevel != LogLevel.off) {
|
||||||
|
closure(logLevel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onChange(BlocBase<dynamic> bloc, Change<dynamic> change) {
|
void onChange(BlocBase<dynamic> bloc, Change<dynamic> change) {
|
||||||
super.onChange(bloc, change);
|
super.onChange(bloc, change);
|
||||||
log.debug('Change: ${bloc.runtimeType} $change');
|
_checkLogLevel(_blocChangeLogLevels, LogLevel.debug, bloc, (logLevel) {
|
||||||
|
log.log(logLevel, 'Change: ${bloc.runtimeType} $change');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onCreate(BlocBase<dynamic> bloc) {
|
void onCreate(BlocBase<dynamic> bloc) {
|
||||||
super.onCreate(bloc);
|
super.onCreate(bloc);
|
||||||
log.debug('Create: ${bloc.runtimeType}');
|
_checkLogLevel(_blocCreateCloseLogLevels, LogLevel.debug, bloc, (logLevel) {
|
||||||
|
log.log(logLevel, 'Create: ${bloc.runtimeType}');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onClose(BlocBase<dynamic> bloc) {
|
void onClose(BlocBase<dynamic> bloc) {
|
||||||
super.onClose(bloc);
|
super.onClose(bloc);
|
||||||
log.debug('Close: ${bloc.runtimeType}');
|
_checkLogLevel(_blocCreateCloseLogLevels, LogLevel.debug, bloc, (logLevel) {
|
||||||
|
log.log(logLevel, 'Close: ${bloc.runtimeType}');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onError(BlocBase<dynamic> bloc, Object error, StackTrace stackTrace) {
|
void onError(BlocBase<dynamic> bloc, Object error, StackTrace stackTrace) {
|
||||||
super.onError(bloc, error, stackTrace);
|
super.onError(bloc, error, stackTrace);
|
||||||
log.error('Error: ${bloc.runtimeType} $error\n$stackTrace');
|
_checkLogLevel(_blocErrorLogLevels, LogLevel.error, bloc, (logLevel) {
|
||||||
|
log.log(logLevel, 'Error: ${bloc.runtimeType} $error\n$stackTrace');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user