Logger class abstract
Logger is used to emit logging messages.
There are three types of Logger: hierarchical logger - named logger using a hierarchical dot-separated namespaces; detached logger - optionally named logger that isn't part of any logger hierarchy and noop logger - logger that does nothing.
Logger objects may be obtained by calling Logger.getLogger, Logger.detached or Logger.noop factories. Logger.getLogger returns a hierarchical logger by either creating it or obtaining existing one. Logger.detached always returns a new logger regardless to the provided logger name, typically such loggers are necessary if short-living logger is needed which may be garbage collected later. Logger.noop returns a no operation logger.
Each logger has a severity level reflecting a minimum severity level of logging message this logger cares about (see Logger.level). It's possible to register a logging message filter that filters messages based on various criteria (see Logger.filter).
To log a message use Logger.log method or one of its derivatives such
Logger.debug
, Logger.info
, etc. On each Logger.log calls logger
performs a severity level check and discarding those messages which have
severity level this logger doesn't cares about; if message passes severity
level check it then filtered out by a registered logger filter if any.
Those messages which pass both checks delegated to a registered handler if
any (see Logger.handler).
To bind structured data to the logging context call Logger.bind with data represented as a collection of Fields. Calling to Logger.bind will result into a new context with logging capabilities and bound collection of fields has been created.
- Implemented types
- Implementers
- Available Extensions
Constructors
- Logger.detached([String? name])
-
Creates a new detached logger.
factory
- Logger.getLogger(String name)
-
Retrieves a logger with
name
. If the logger already exists, then it will be returned, otherwise a new logger is created.factory - Logger.noop([String? name])
-
Creates a new noop logger which never emits logs and never
delegates records to handlers.
factory
Properties
- filter ← Filter?
-
Set this logger filter.
no getter
- handler ← Handler?
-
Sets this logger logs handler.
no getter
- hashCode → int
-
The hash code for this object.
no setterinherited
- level ↔ Level
-
Retrieves minimum severity level of Records this logger cares about.
getter/setter pair
- name → String?
-
Name of this logger.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
bind(
[Iterable< Field> ? fields]) → Interface -
Creates and returns a new logging context with bound collection of
fields
added to existing one.inherited -
isEnabledFor(
Level level) → bool -
Tests whether record with severity
level
will be emitted by this logger. -
log(
Level level, String message) → void -
Emits a record with
message
andlevel
severity level.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
trace(
String message, {Level level = Level.debug}) → Tracer -
Starts tracing and emits a record with
message
andlevel
severity level; to stop tracing call Tracer.stop on the returned tracer.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited