Logger class

Main logd interface.

Use this class for logging operations. It provides methods to retrieve loggers with hierarchical support, global fallback logger, and configuration options.

This class acts as a proxy to the logger's configuration, resolving values dynamically from the Logger tree hierarchy on each access for up-to-date settings.

Properties

autoSinkBuffer bool
Whether to auto-sink abandoned buffers.
no setter
debugBuffer LogBuffer?
Returns a buffer for building multi-line debug-level logs.
no setter
enabled bool
Whether logging is enabled for this logger.
no setter
errorBuffer LogBuffer?
Returns a buffer for building multi-line error-level logs.
no setter
explicitFields Set<String>
The set of fields that have been explicitly configured on this logger.
no setter
frozenFields Set<String>
The set of fields that were frozen on this logger by freezeInheritance.
no setter
handlers List<Handler>
List of handlers to process log entries.
no setter
hashCode int
The hash code for this object.
no setterinherited
includeFileLineInHeader bool
Whether to include file path and line number in the origin string.
no setter
infoBuffer LogBuffer?
Returns a buffer for building multi-line info-level logs.
no setter
inheritedFields Set<String>
The set of fields that are currently inherited from ancestor loggers.
no setter
logLevel LogLevel
The minimum level to log (events below this are dropped).
no setter
name String
Logger's unique name
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stackMethodCount Map<LogLevel, int>
Map of how many stack frames to include per log level.
no setter
stackTraceParser StackTraceParser
The stack trace parser configuration.
no setter
timestamp Timestamp
The timestamp formatter configuration.
no setter
traceBuffer LogBuffer?
Returns a buffer for building multi-line trace-level logs.
no setter
warningBuffer LogBuffer?
Returns a buffer for building multi-line warning-level logs.
no setter

Methods

debug(Object? message, {Map<String, dynamic>? context, Object? error, StackTrace? stackTrace}) → void
Logs a debug-level message.
error(Object? message, {Map<String, dynamic>? context, Object? error, StackTrace? stackTrace}) → void
Logs an error-level message.
freezeInheritance({bool force = false}) int
Freezes the current inherited configurations into descendant loggers.
info(Object? message, {Map<String, dynamic>? context, Object? error, StackTrace? stackTrace}) → void
Logs an info-level message.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
trace(Object? message, {Map<String, dynamic>? context, Object? error, StackTrace? stackTrace}) → void
Logs a trace-level message.
unfreezeInheritance({Set<String>? fields, bool includeSelf = true}) → void
Unfreezes configurations that were previously frozen on descendant loggers.
warning(Object? message, {Map<String, dynamic>? context, Object? error, StackTrace? stackTrace}) → void
Logs a warning-level message.

Operators

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

Static Properties

fallbackHandler ↔ void Function(LogEntry entry, Object? error, StackTrace? stackTrace)?
Callback triggered when all configured handlers fail.
getter/setter pair
maxHierarchyDepth int
The maximum hierarchy depth allowed before a warning is printed. Defaults to 10.
getter/setter pair

Static Methods

configure(String name, {bool? enabled, LogLevel? logLevel, bool? includeFileLineInHeader, Map<LogLevel, int>? stackMethodCount, Timestamp? timestamp, StackTraceParser? stackTraceParser, List<Handler>? handlers, bool? autoSinkBuffer}) → void
Configures a logger's properties, updating the config in-place.
configureMultiple(Map<String, LoggerConfig> configurations) → void
Configures multiple loggers at once, applying their properties in-place.
configurePattern(String pattern, {bool? enabled, LogLevel? logLevel, bool? includeFileLineInHeader, Map<LogLevel, int>? stackMethodCount, Timestamp? timestamp, StackTraceParser? stackTraceParser, List<Handler>? handlers, bool? autoSinkBuffer}) → void
Configures loggers matching a wildcard or regular expression pattern.
exportConfig() Map<String, dynamic>
Exports the current configurations of all loggers registered.
exportHierarchy() Map<String, dynamic>
Exports the registry configuration hierarchy.
formatHierarchy() String
Returns a formatted string representation of the active logger hierarchy.
get([String? name]) Logger
  • Basic: Logger.get('app').info('Message');
  • Global: Logger.get(), Logger.get(''), Logger.get('global')
  • importConfig(Map<String, dynamic> configData) → void
    Imports and applies configurations exported via exportConfig.
    printHierarchy({void sink(String)?}) → void
    Prints a visual representation of the active logger hierarchy.
    removePattern(String pattern) → void
    Removes a pattern rule from the pattern configuration rules list.
    reset([String? loggerName]) → void
    Clears the logger registry for the specified loggerName and all its descendants, restoring them to default unresolved settings.