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

Constructors

FlatPrinter({LogConfig? config})
A simple, flat-style log printer that outputs log records in a structured format.

Properties

config LogConfig
Configuration object that determines which log steps to include.
final
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.
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