HybridPrinter class final
A hybrid log printer that delegates printing based on log level.
This printer uses a SimplePrinter for DEBUG level logs (to maintain minimal,
performance-friendly output during development), and a PrettyPrinter for all
other levels, providing detailed and styled logs for higher severity messages.
Ideal for situations where verbose output is only needed for higher severity, while keeping debug logs concise.
Example
final printer = HybridPrinter(
config: LogConfig(showTimestamp: true, showLevel: true),
);
final debugLog = LogRecord(
level: LogLevel.DEBUG,
message: 'Debug info',
time: DateTime.now(),
);
final errorLog = LogRecord(
level: LogLevel.ERROR,
message: 'Something went wrong!',
time: DateTime.now(),
);
printer.log(debugLog); // Uses SimplePrinter
printer.log(errorLog); // Uses PrettyPrinter
- Inheritance
-
- Object
- LogPrinter
- HybridPrinter
Constructors
- HybridPrinter({LogConfig? config, LogPrinter? prettyPrinter, LogPrinter? simplePrinter})
- A hybrid log printer that delegates printing based on log level.
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.
inherited
-
getStepValue(
LogStep step, LogRecord record) → String? -
Extracts the string representation of the given LogStep from a LogRecord.
inherited
-
levelColor(
LogLevel level) → AnsiColor -
Returns the color for the given log level.
inherited
-
log(
LogRecord record) → List< String> -
Formats the given LogRecord into a list of strings.
override
-
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.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited