Logar class
Centralized logging utility - Logar
A comprehensive, singleton-based logging system that supports:
- Multiple log levels (debug, info, warning, error, fatal)
- Tagging and custom prefixes
- JSON and pretty-print output formats
- Global enable/disable toggle
- External log collector integration (Firebase Crashlytics, etc.)
- Clean architecture compliance
- Platform-agnostic design
Usage:
// Basic logging
Logar.debug('Debug message');
Logar.info('Info message');
Logar.warning('Warning message');
Logar.error('Error message');
Logar.fatal('Fatal error');
// With tags
Logar.debug('Network request started', tag: 'NETWORK');
// With additional data
Logar.info('User logged in', data: {'userId': '123', 'email': 'user@example.com'});
// With errors and stack traces
try {
// some code
} catch (error, stackTrace) {
Logar.error('Operation failed', error: error, stackTrace: stackTrace);
}
// Configuration
Logar.configure(LogarConfig(
minimumLevel: LogLevel.info,
format: LogFormat.json,
enabled: true,
));
// Add external collectors
Logar.addCollector(FirebaseCrashlyticsCollector());
Centralized logging utility for the Amwal Pay SDK.
Supports multiple log levels, output formats, and external log collectors.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
Static Methods
-
addCollector(
LogCollector collector) → Future< void> - Add an external log collector Add an external log collector.
-
clearCollectors(
) → Future< void> - Clear all log collectors Clear all log collectors.
-
clearHistory(
) → void - Clear log history Clear log history.
-
configure(
LogarConfig config) → void - Configure Logar with custom settings Configure Logar with custom settings.
-
debug(
String message, {String? tag, Map< String, dynamic> ? data, Object? error, StackTrace? stackTrace}) → void - Log a debug message Log a debug message.
-
dispose(
) → Future< void> - Dispose Logar and clean up resources
-
error(
String message, {String? tag, Map< String, dynamic> ? data, Object? error, StackTrace? stackTrace}) → void - Log an error message Log an error message.
-
fatal(
String message, {String? tag, Map< String, dynamic> ? data, Object? error, StackTrace? stackTrace}) → void - Log a fatal error message Log a fatal error message.
-
info(
String message, {String? tag, Map< String, dynamic> ? data, Object? error, StackTrace? stackTrace}) → void - Log an info message Log an info message.
-
removeCollector(
LogCollector collector) → Future< void> - Remove a log collector Remove a log collector.
-
reset(
) → void - Reset Logar to initial state.
-
setEnabled(
bool enabled) → void - Enable or disable logging globally Enable or disable logging globally.
-
setFormat(
LogFormat format) → void - Set log format Set log format.
-
setMinimumLevel(
LogLevel level) → void - Set minimum log level Set minimum log level.
-
warning(
String message, {String? tag, Map< String, dynamic> ? data, Object? error, StackTrace? stackTrace}) → void - Log a warning message Log a warning message.