contextual
2.2.0, released 10 months ago by glenfordwilliams.com
A structured logging library with context, middleware, and multiple output channels.
What it does
Provides hierarchical named loggers, flexible formatting (JSON, logfmt, colored), and supports custom drivers. Allows adding context, middleware, and asynchronous batching for efficient log processing.
AI-written summary of version 2.2.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need structured, multi‑channel logging in a Dart/Flutter app
- You want context propagation and hierarchical loggers
- You require custom formatting or middleware for logs
Skip it when
- You only need simple console prints
- You prefer a built‑in Flutter logger without extra configuration
Strengths
- Rich context and hierarchical logger support
- Multiple output drivers and per‑channel formatters
- Middleware and async batching for performance
Weaknesses
- Adds extra dependency and setup compared to basic print statements
- May be overkill for tiny projects
- Learning curve for configuration and channel management
Setup
- Kind
- Pure Dart
- Effort
- Medium
- Code generation
- No
- Direct dependencies
- 6
Add the package to pubspec, then create a Logger and optionally configure channels/formatters; no native permissions required
import 'package:contextual/contextual.dart';
void main() {
final logger = Logger(level: Level.info)..withContext({'app':'MyApp'});
logger.info('Application started');
logger.error('Something went wrong');
}Alternatives
Packages that do the same job and could replace contextual.
- talker_riverpod_logger
Lightweight and customizable Riverpod state management logger based on Talker.
87Compare - talker_bloc_logger
Lightweight and customizable logger for BLoC and Cubit built on Talker.
89Compare - flutter_fimber
Flutter extension for Fimber logging API to use native OS logging via platform channels.
40Compare
Works with
Packages commonly used together with contextual: ones it builds on, ones built on it, and its own family.
- intlcontextual depends on itA Dart library for internationalization and localization, providing message translation, plural/gender handling, and date/number formatting.
- universal_iocontextual depends on itCross-platform dart:io implementation with browser support for HttpClient and other APIs
- ansicolorcontextual depends on itAn xterm-256 color support library for changing terminal text colors and backgrounds.
- dart_mappablecontextual depends on itJSON serialization and data classes generator supporting generics, inheritance, and customization.