ispectify_bloc 4.1.3-dev12 copy "ispectify_bloc: ^4.1.3-dev12" to clipboard
ispectify_bloc: ^4.1.3-dev12 copied to clipboard

An additional package for BLoC (logging and handling).

BLoC state management integration for ISpectify logging system

pub version License: MIT GitHub stars

Pub likes Pub points

πŸ” Overview #

ISpectify BLoC provides seamless integration between BLoC state management and the ISpectify logging system.

πŸ”„ State Tracking β€’ πŸ“ Event Logging β€’ πŸ” Transition Monitoring β€’ ❌ Error Handling

Enhance your BLoC debugging workflow by automatically capturing and logging all state management interactions. Perfect for tracking state changes, debugging complex flows, and monitoring application behavior.

🎯 Key Features #

  • πŸ”„ State Change Logging: Automatic logging of all BLoC state changes
  • πŸ“ Event Tracking: Detailed event logging with parameters
  • πŸ” Transition Monitoring: Complete state transition tracking
  • ❌ Error Handling: BLoC error logging with stack traces
  • ⚑ Performance Metrics: State change timing and performance tracking
  • πŸŽ›οΈ Configurable: Flexible filtering and formatting options

πŸ”§ Configuration Options #

Basic Configuration #

Bloc.observer = ISpectifyBlocObserver(
  ispectify: ispectify,
  settings: ISpectifyBlocSettings(
    // Event logging
    printEvents: true,
    
    // State logging
    printStates: true,
    
    // Transition logging
    printTransitions: true,
    
    // Change logging
    printChanges: true,
    
    // Error handling
    printErrors: true,
  ),
);

Advanced Filtering #

Bloc.observer = ISpectifyBlocObserver(
  ispectify: ispectify,
  settings: ISpectifyBlocSettings(
    // Filter specific BLoCs
    blocFilter: (bloc) => bloc.runtimeType != NavigationBloc,
    
    // Filter sensitive events
    eventFilter: (event) {
      if (event is AuthEvent) {
        return event.copyWith(password: '***');
      }
      return event;
    },
    
    // Filter states
    stateFilter: (state) {
      if (state is UserState) {
        return state.copyWith(sensitiveData: null);
      }
      return state;
    },
    
    // Custom log levels
    eventLogLevel: LogLevel.debug,
    stateLogLevel: LogLevel.info,
    errorLogLevel: LogLevel.error,
  ),
);

πŸ“¦ Installation #

Add ispectify_bloc to your pubspec.yaml:

dependencies:
  ispectify_bloc: ^4.1.3

πŸš€ Quick Start #

import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:ispectify_bloc/ispectify_bloc.dart';
import 'package:ispectify/ispectify.dart';

void main() {
  final ispectify = ISpectify();
  
  // Set up BLoC observer
  Bloc.observer = ISpectifyBlocObserver(
    ispectify: ispectify,
    settings: ISpectifyBlocSettings(
      printEvents: true,
      printStates: true,
      printTransitions: true,
      printChanges: true,
    ),
  );
  
  runApp(MyApp());
}

// Your BLoC will be automatically logged
class CounterBloc extends Bloc<CounterEvent, int> {
  CounterBloc() : super(0) {
    on<CounterIncremented>((event, emit) {
      emit(state + 1);
    });
  }
}

βš™οΈ Advanced Features #

Custom Log Formatting #

Bloc.observer = ISpectifyBlocObserver(
  ispectify: ispectify,
  settings: ISpectifyBlocSettings(
    eventFormatter: (bloc, event) => '${bloc.runtimeType}: ${event.runtimeType}',
    stateFormatter: (bloc, state) => '${bloc.runtimeType} -> ${state.runtimeType}',
    transitionFormatter: (bloc, transition) => 
      '${bloc.runtimeType}: ${transition.event.runtimeType} -> ${transition.nextState.runtimeType}',
  ),
);

Performance Monitoring #

Bloc.observer = ISpectifyBlocObserver(
  ispectify: ispectify,
  settings: ISpectifyBlocSettings(
    trackPerformance: true,
    performanceThreshold: Duration(milliseconds: 100), // Log slow transitions
  ),
);

Multiple Observers #

// Combine with other observers
class MultiBlocObserver extends BlocObserver {
  final List<BlocObserver> _observers;
  
  MultiBlocObserver(this._observers);
  
  @override
  void onChange(BlocBase bloc, Change change) {
    for (final observer in _observers) {
      observer.onChange(bloc, change);
    }
  }
  
  // Implement other methods...
}

Bloc.observer = MultiBlocObserver([
  ISpectifyBlocObserver(ispectify: ispectify),
  CustomBlocObserver(),
]);

πŸ“š Examples #

See the example/ directory for complete integration examples with different BLoC patterns.

πŸ—οΈ Architecture #

ISpectifyBloc integrates with the BLoC library through observers:

Component Description
BLoC Observer Captures all BLoC events and state changes
Event Logger Logs events with parameters and metadata
State Logger Logs state changes and transitions
Error Handler Captures and logs BLoC errors
Performance Tracker Measures state change performance

🀝 Contributing #

Contributions are welcome! Please read our contributing guidelines and submit pull requests to the main branch.

πŸ“„ License #

This project is licensed under the MIT License - see the LICENSE file for details.

  • ispectify - Foundation logging system
  • ispect - Main debugging interface
  • flutter_bloc - BLoC state management library
  • bloc - Core BLoC library

Built with ❀️ for the Flutter community

0
likes
0
points
1.39k
downloads

Publisher

verified publishershodev.live

Weekly Downloads

An additional package for BLoC (logging and handling).

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

bloc, ispectify, meta

More

Packages that depend on ispectify_bloc