NamedLogger class

A named logger that automatically includes a logger name in the context.

Named loggers are useful for organizing logs by module or component. The logger name is injected into the context as _loggerName and displayed as a prefix in console output.

Example:

final authLogger = logger.named('auth');
final paymentLogger = logger.named('payment');

authLogger.info('User logged in');      // context: {_loggerName: 'auth'}
paymentLogger.error('Payment failed');  // context: {_loggerName: 'payment'}

Constructors

NamedLogger(StrategicLogger _logger, String name)
Creates a named logger that delegates to _logger with name injected into context.

Properties

hashCode int
The hash code for this object.
no setterinherited
name String
The name of this logger instance.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

debug(dynamic message, {LogEvent? event, Map<String, Object>? context}) → void
Logs a debug message with this logger's name in context.
error(dynamic error, {StackTrace? stackTrace, LogEvent? event, Map<String, Object>? context}) → void
Logs an error with this logger's name in context.
fatal(dynamic error, {StackTrace? stackTrace, LogEvent? event, Map<String, Object>? context}) → void
Logs a fatal error with this logger's name in context.
info(dynamic message, {LogEvent? event, Map<String, Object>? context}) → void
Logs an info message with this logger's name in context.
log(dynamic message, {LogEvent? event, Map<String, Object>? context}) → void
Logs a message with this logger's name in context.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
verbose(dynamic message, {LogEvent? event, Map<String, Object>? context}) → void
Logs a verbose message (alias for debug) with this logger's name in context.
warning(dynamic message, {LogEvent? event, Map<String, Object>? context}) → void
Logs a warning message with this logger's name in context.

Operators

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