LogPrinter class abstract
A base class for implementing custom log output formatting.
Subclasses of LogPrinter are responsible for formatting a LogRecord into one or more strings for display, file logging, or other destinations.
Log printers provide flexibility in how logs are presented, making them essential for different environments such as terminals, files, remote logging services, or testing frameworks.
Example:
class SimpleLogPrinter extends LogPrinter {
@override
List<String> log(LogRecord record) {
return ['${record.time.toIso8601String()} [${record.level}] ${record.message}'];
}
}
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
extractStack(
StackTrace? stackTrace, List< String> excludePaths) → List<String> - Extracts the stack trace from a LogRecord.
-
getStepValue(
LogStep step, LogRecord record) → String? - Extracts the string representation of the given LogStep from a LogRecord.
-
levelColor(
LogLevel level) → AnsiColor - Returns the color for the given log level.
-
log(
LogRecord record) → List< String> - Formats the given LogRecord into a list of strings.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
stringify(
dynamic message) → String - Converts a message to its string representation.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
get(
LogType type, LogConfig config) → LogPrinter -
Returns a new LogPrinter instance for the given
type
.