Log class
Zone-based logger with automatic context propagation.
Use Log.named to create a named logger for classes:
class UserService {
static final log = Log.named('UserService');
Future<User> findUser(String id) async {
log.info('Finding user', {'userId': id});
// Output: ... [INFO] Finding user logger=UserService userId=42
return await _repository.find(id);
}
}
For quick logging without a class name, use the top-level log constant:
log.info('message');
Properties
Methods
-
debug(
String message, [Map< String, dynamic> ? fields]) → void - Logs a debug message.
-
error(
String message, [Map< String, dynamic> ? fields, Object? err, StackTrace? stackTrace]) → void - Logs an error message.
-
info(
String message, [Map< String, dynamic> ? fields]) → void - Logs an info message.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
warn(
String message, [Map< String, dynamic> ? fields]) → void - Logs a warning message.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
-
currentContext
→ Map<
String, dynamic> -
Gets the current zone context fields.
no setter