Logging & Debugging
Centralized logging and state tracking with Talker.
The boilerplate uses Talker to provide a centralized, robust logging system. This helps developers track app behavior, debug issues, and monitor state changes in real-time.
Overview
We use a global talker instance to handle all application logs. It's configured to capture everything from simple debug messages to complex Riverpod state transitions and network requests.
🏗 Architecture
1. Global Instance
A single talker instance is defined in lib/helpers/log.dart:
import 'package:talker/talker.dart';
final talker = Talker();2. Riverpod Observation
We track every state change in the application by adding TalkerRiverpodObserver to the ProviderScope in main.dart:
ProviderScope(
observers: [TalkerRiverpodObserver()],
child: MyApp(...),
)3. Network Logging
Our custom Dio client (in DioService) is integrated with Talker to log every HTTP request and response, including headers, payloads, and errors.
🚀 Usage
Simple Logging
Use the talker instance anywhere in your code:
import 'package:mobile/helpers/log.dart';
talker.debug("User opened the settings page");
talker.info("Theme changed to dark mode");
talker.warning("Low disk space detected");
talker.error("Failed to fetch profile", exception, stackTrace);Viewing Logs
During development, logs are printed to the console in a formatted, color-coded way. You can also integrate a UI for Talker to view logs directly inside the app (useful for beta testing).
Integration points
Talker is integrated with:
- Riverpod: Captures
didUpdateProvider,didAddProvider, anddidDisposeProvider. - Dio: Captures all HTTP traffic.
- Firebase: Logs background message handling and token reception.
- App Lifecycle: Logs when the app resumes or transitions between states.