FlatPrinter class final
A simple, flat-style log printer that outputs log records in a structured format.
This printer formats each log record as a single line, with each configured step enclosed in square brackets. It is useful for compact and readable logging output in CLI or file logs.
The formatting behavior is controlled by the LogConfig object, allowing you to choose which log information to include, such as timestamp, level, tag, message, error, stack trace, and more.
Example
final printer = FlatPrinter();
final record = LogRecord(
level: LogLevel.info,
message: 'App started',
time: DateTime.now(),
loggerName: 'AppLogger',
);
final output = printer.log(record);
print(output.first); // Example: [INFO][AppLogger][App started]
- Inheritance
-
- Object
- LogPrinter
- FlatPrinter
Constructors
- FlatPrinter({LogConfig? config})
- A simple, flat-style log printer that outputs log records in a structured format.
Properties
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.
override
-
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