Logger Easier
π Project Introduction
Logger Easier is a modern logging management solution tailored specifically for Dart and Flutter applications. It provides a highly flexible and feature-rich logging system designed to simplify developers' log management while offering significant customization capabilities.
β¨ Core Features
-
Multi-Level Log Management
- Supports 7 log levels: Trace, Debug, Info, Warn, Error, Critical, Fatal
- Fine-grained log level control
- Configurable minimum log recording level
-
Flexible Log Output
- Console output (supports colored logs)
- File logging
- Custom output destinations
- Log file rotation and compression
-
Advanced Log Formatting
- Customizable log formats
- Supports multiple log format templates
- Rich log record metadata (timestamps, source, error information, etc.)
-
Performance Monitoring
- Built-in performance measurement methods
- Async and sync operation performance tracking
- Automatic performance metric recording and reporting
-
Error Handling
- Automatic error reporting
- Stack trace recording
- Pluggable error reporter
-
Singleton Mode
- Unified global log management
- Simple initialization and usage
-
Extensibility
- Supports custom log processors
- Pluggable components (printers, outputs, formatters, filters)
π¦ Installation
Add the dependency in pubspec.yaml
:
dependencies:
logger_easier: ^0.0.1
Run dart pub get
or flutter pub get
to install the dependency.
π Quick Start
Basic Usage
import 'package:logger_easier/logger_easier.dart';
void main() {
// Create default logger instance
final logger = Logger();
// Log different levels
logger.debug('Debug information');
logger.info('General information');
logger.warn('Warning information');
logger.error('Error information', error: Exception('Sample error'));
}
File Logging Configuration
final logger = Logger(
logDirectory: '/path/to/logs',
baseFileName: 'app.log',
maxFileSize: 10 * 1024 * 1024, // 10MB
maxBackupIndex: 5,
compress: true,
);
Performance Measurement
// Async performance measurement
final result = await logger.measurePerformance('complex_operation', () async {
return await complexOperation();
});
// Sync performance measurement
final syncResult = logger.measureSyncPerformance('simple_operation', () {
return simpleOperation();
});
Custom Log Processing
final customLogger = Logger(
middlewares: [
LogMiddleware(
printer: CustomPrinter(),
output: CustomOutput(),
formatter: CustomFormatter(),
filter: CustomFilter(),
)
]
);
π Log Levels
Logger Easier supports 7 log levels, increasing in severity:
trace
: Most detailed tracing information, for fine-grained diagnosticsdebug
: Debug information, used for development and diagnosticsinfo
: Regular information, important application eventswarn
: Warning information, potential problems or exceptional situationserror
: Error information, issues causing functional anomaliescritical
: Critical errors, severely affecting system operationfatal
: Fatal errors, system unable to continue running
π Best Practices
- Initialize logging during application startup
- Use appropriate log levels
- Disable verbose logs in production environments
- Regularly clean and archive log files
- Protect sensitive information, avoid recording sensitive data in logs
π License
This project is licensed under the MIT License. See the LICENSE file for details.
π€ Contribution Guidelines
Welcome to participate in the project through:
- Submitting Issues
- Initiating Pull Requests
- Improving documentation
- Sharing usage experiences
Please read CONTRIBUTING.md for detailed contribution guidelines.
π Support and Contact
- GitHub Issues: Submit Issue
- Email: 291148484@163.com
π Language Support
Note: Logger Easier is under continuous development, and the API may change. It is recommended to follow version updates. This documentation may be updated later than the code, so please be sure to refer to the example project for usage.