2023-12-26 20:26:54 -05:00
|
|
|
import 'package:bloc/bloc.dart';
|
2023-09-26 22:32:18 -04:00
|
|
|
import 'loggy.dart';
|
|
|
|
|
2023-12-26 20:26:54 -05:00
|
|
|
/// [BlocObserver] for the VeilidChat application that
|
|
|
|
/// observes all state changes.
|
|
|
|
class StateLogger extends BlocObserver {
|
|
|
|
/// {@macro counter_observer}
|
2023-09-26 22:32:18 -04:00
|
|
|
const StateLogger();
|
2023-12-26 20:26:54 -05:00
|
|
|
|
2023-09-26 22:32:18 -04:00
|
|
|
@override
|
2023-12-26 20:26:54 -05:00
|
|
|
void onChange(BlocBase<dynamic> bloc, Change<dynamic> change) {
|
|
|
|
super.onChange(bloc, change);
|
|
|
|
log.debug('Change: ${bloc.runtimeType} $change');
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void onCreate(BlocBase<dynamic> bloc) {
|
|
|
|
super.onCreate(bloc);
|
|
|
|
log.debug('Create: ${bloc.runtimeType}');
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void onClose(BlocBase<dynamic> bloc) {
|
|
|
|
super.onClose(bloc);
|
|
|
|
log.debug('Close: ${bloc.runtimeType}');
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void onError(BlocBase<dynamic> bloc, Object error, StackTrace stackTrace) {
|
|
|
|
super.onError(bloc, error, stackTrace);
|
|
|
|
log.error('Error: ${bloc.runtimeType} $error\n$stackTrace');
|
2023-09-26 22:32:18 -04:00
|
|
|
}
|
|
|
|
}
|