VooLogger class
A zero-config logger for Flutter applications.
VooLogger works immediately without any setup:
import 'package:voo_logging/voo_logging.dart';
VooLogger.info('App started');
VooLogger.debug('Loading data...');
VooLogger.warning('Cache miss');
VooLogger.error('Request failed', error: e);
Structured Logging
Add context with categories, tags, and metadata:
VooLogger.info(
'Purchase completed',
category: 'Payment',
tag: 'checkout',
metadata: {'orderId': 'ORD-123', 'amount': 99.99},
);
Configuration
Customize output format and behavior:
await VooLogger.initialize(
config: LoggingConfig(
enablePrettyLogs: true, // Formatted output with borders
showEmojis: true, // Level icons
showTimestamp: true, // HH:MM:SS.mmm
showMetadata: false, // Hide metadata section
minimumLevel: LogLevel.info,
),
);
Or use presets:
await VooLogger.initialize(config: LoggingConfig.production());
await VooLogger.initialize(config: LoggingConfig.development());
Real-time Log Stream
VooLogger.instance.stream.listen((log) {
print('${log.level}: ${log.message}');
});
See also:
- LoggingConfig for configuration options
- VooDioInterceptor for automatic HTTP logging
- LogLevel for available log levels
Constructors
- VooLogger()
-
factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- repository → LoggerRepository
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
stream
→ Stream<
LogEntry> -
no setter
Methods
-
clearLogs(
) → Future< void> -
getLogs(
{LogFilter? filter}) → Future< List< LogEntry> > -
getStatistics(
) → Future< LogStatistics> -
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
- config ↔ LoggingConfig
-
getter/setter pair
- instance → VooLogger
-
final
- isInitialized → bool
-
Returns true if VooLogger has been initialized.
no setter
Static Methods
-
debug(
String message, {String? category, String? tag, Map< String, dynamic> ? metadata}) → Future<void> - Log a debug message. Auto-initializes if needed.
-
ensureInitialized(
{String? appName, String? appVersion, String? userId, LoggingConfig? config}) → Future< void> - Ensures VooLogger is initialized. Safe to call multiple times.
-
error(
String message, {Object? error, StackTrace? stackTrace, String? category, String? tag, Map< String, dynamic> ? metadata, bool shouldNotify = false}) → Future<void> - Log an error message. Auto-initializes if needed.
-
fatal(
String message, {Object? error, StackTrace? stackTrace, String? category, String? tag, Map< String, dynamic> ? metadata, bool shouldNotify = false}) → Future<void> - Log a fatal error message. Auto-initializes if needed.
-
info(
String message, {String? category, String? tag, Map< String, dynamic> ? metadata, bool shouldNotify = false}) → Future<void> - Log an info message. Auto-initializes if needed.
-
initialize(
{String? appName, String? appVersion, String? userId, LoggingConfig? config}) → Future< void> - Initialize VooLogger with optional configuration.
-
log(
String s, {required LogLevel level, String? category, Map< String, Object> ? metadata, String? tag}) → Future<void> - Log a message with custom level. Auto-initializes if needed.
-
networkRequest(
String s, String t, {required Map< String, String> headers, required Map<String, String> metadata}) → Future<void> - Log a network request. Auto-initializes if needed.
-
userAction(
String s, {required String screen, required Map< String, Object> properties}) → Future<void> - Log a user action. Auto-initializes if needed.
-
verbose(
String message, {String? category, String? tag, Map< String, dynamic> ? metadata}) → Future<void> - Log a verbose message. Auto-initializes if needed.
-
warning(
String message, {String? category, String? tag, Map< String, dynamic> ? metadata, bool shouldNotify = false}) → Future<void> - Log a warning message. Auto-initializes if needed.