Logger class

Central logging facility with support for:

  • Multiple transports
  • Hierarchical context via child()
  • Structured logging
  • Async, fault-tolerant delivery

Example:

final logger = Logger(transports: [ConsoleTransport()]);
await logger.info('Server started', {'port': 8080});

Constructors

Logger({List<LogTransport>? transports, Map<String, dynamic>? context})
Creates a logger with optional transports and context.

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

child([Map<String, dynamic>? additionalContext]) Logger
Creates a child logger with additional context.
debug(String message, [Map<String, dynamic>? metadata]) Future<void>
Logs a debug message.
dispose() Future<void>
Disposes all transports.
error(String message, [Map<String, dynamic>? metadata]) Future<void>
Logs an error message.
info(String message, [Map<String, dynamic>? metadata]) Future<void>
Logs an info message.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
success(String message, [Map<String, dynamic>? metadata]) Future<void>
Logs a success message.
toString() String
A string representation of this object.
inherited
trace(String message, [Map<String, dynamic>? metadata]) Future<void>
Logs a trace message.
warn(String message, [Map<String, dynamic>? metadata]) Future<void>
Logs a warning message.

Operators

operator ==(Object other) bool
The equality operator.
inherited