A collection of Dart packages that provide powerful, flexible, and structured logging capabilities.
The core logging package that provides structured, multi-channel logging with context support.
final logger = Logger()
..addChannel('console', ConsoleLogDriver())
..info('Hello, World!', Context({'user': 'alice'}));
Key features:
- Multiple output channels
- Structured logging with context
- Flexible formatting options
- Error handling and stack traces
- Performance monitoring
Shelf middleware for HTTP request logging and monitoring.
final httpLogger = HttpLogger(logProfile, logWriter);
final handler = Pipeline()
.addMiddleware(httpLogger.middleware)
.addHandler(myHandler);
Key features:
- Request/response logging
- Performance metrics
- Header sanitization
- Custom request filtering
- Multiple output formats
- Add the desired packages to your
pubspec.yaml
:
dependencies:
contextual: ^1.0.0
contextual_shelf: ^1.0.0 # If using Shelf
- Import and use:
import 'package:contextual/contextual.dart';
final logger = Logger()
..addChannel(
'console',
ConsoleLogDriver(),
formatter: PrettyLogFormatter(),
);
logger.info('Application started');
Each package contains detailed examples in its example
directory:
- 📝 Structured Logging: Rich, structured log entries with context
- 🎨 Multiple Formats: JSON, pretty-printed, and plain text output
- 🔄 Flexible Routing: Send different logs to different destinations
- 🔍 Context Support: Add structured data to your logs
- 🚀 Performance: Efficient logging with minimal overhead
- 🛠️ Extensible: Easy to add custom drivers and formatters
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Clone the repository:
git clone https://github.com/kingwill101/contextual.git
cd contextual
- Get dependencies:
dart pub get
- Run tests:
dart test
This project is licensed under the MIT License - see the LICENSE file for details.