JsonLogger class final
The JsonLogger class is a logger that records log messages in JSON format.
It implements the ILogRecorder interface and provides the following features:
- supports configurable log levels.
- can be used to record log messages to any output stream, such as the console, a file, or a network socket.
- uses a customizable mapper to convert LogRecordEntity objects to JSON maps.
- uses a customizable serializer to serialize JSON maps to strings.
- Inheritance
-
- Object
- ILogRecorder
- JsonLogger
Constructors
- JsonLogger({required int logLevel, RecordMapper? mapper, JsonSerializer? serializer, void output(String) = print})
- The JsonLogger class is a logger that records log messages in JSON format.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- logLevel → int
-
The logLevel getter returns the log level of the log recorder instance.
This log level represents the minimum level of logs
that will be recorded by this recorder.
final
- mapper → RecordMapper
-
The mapper that converts LogRecordEntity objects to JSON maps.
final
- output → void Function(String)
-
The output stream to which log messages will be recorded.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- serializer → JsonSerializer
-
The serializer that serializes JSON maps to strings.
final
Methods
-
canRecord(
LogRecordEntity record) → bool -
validate whether the current log record should be recorded by
the log recorder instance. By default, it checks if the log level of
the log recorder is equal to or less than the log level of
the given record parameter.
inherited
-
close(
) → void -
called when this particular log recorder is removed from the manager.
It serves as a cleanup or finalization method for any resources or
operations associated with the log recorder.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onRecord(
LogRecordEntity record) → void -
a callback that will be invoked when the manager receives a new log record
that can be recorded by this specific recorder.
It takes a LogRecordEntity object as a parameter, representing
the log record that was received.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited