Resultex Logger 🚀
A lightweight, powerful, and highly compatible logging system for Dart and Flutter. Built directly
on top of native developer.log, it ensures seamless **cross-platform, Web, and WASM compatibility
** without breaking a sweat or relying on heavy external dependencies.
✨ Features
- ✅ Color Logs: High-visibility ANSI escape sequences to colorize your terminal.
- ✅ Comprehensive LogLevels: Full support for
info,verbose,warning,debug,error,critical,fine, andgood. - 🚧 Logs Grouping (In Progress): Visual nesting for hierarchical runtime operations.
- 🚧 Collapsible Huge Logs (In Progress): Smart multi-line layout to handle massive payloads and stack traces cleanly.
📦 Installation
Since this package is tailored for internal/monorepo architectural designs, add it to your
pubspec.yaml using a local path:
dependencies:
resultex_logger:
path: '../error_handler/packages/resultex_logger'
🛠️ Getting Started
- Initialize Dependencies Before using the logger, initialize its dependency injection layer. It is highly recommended to do this in your main.dart before runApp:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Initialize the logger base configuration
final loggerBase = ResultexLoggerBase();
await loggerBase.init();
runApp(const MyApp());
}
- Basic Usage & Log Mapping Import the main entry point and start logging across your application. The logger automatically maps colors, tags, and Syslog levels internally:
import 'package:resultex_logger/logger.dart';
void main() {
// Example usage (Assuming LoggerService is fetched via your DI locator, e.g., GetIt)
final logger = GetIt.I<LoggerService>();
// Standard Logs
logger.info('Application started successfully.');
logger.good('Database connection established.');
logger.fine('Resource allocated smoothly.');
logger.verbose('User scrolling index: 24');
// Warnings & Debugs
logger.warning('API response time is slower than expected.');
logger.debug('Fetching user data dynamic payload...');
// Errors & Critical Crashes
try {
throw Exception('Connection timed out');
} catch (e, stack) {
logger.error('Failed to load dashboard data', error: e, stackTrace: stack);
logger.critical(
'Fatal: System is unable to recover from this state!', error: e, stackTrace: stack);
}
}
🏗️ Architecture Note This package adheres strictly to the Single Responsibility Principle. The AppLogger is decoupled from initialization lifecycles, preventing circular dependencies and making it extremely easy to mock during Unit Testing.
Libraries
- core/di/di_module
- core/di/get_it_config
- core/di/resultex_logger_module
- core/utils/logger_service
- resultex_logger
- The main entry point of the
resultex_loggerpackage.