FlatPrinter constructor

FlatPrinter({
  1. LogConfig? config,
})

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]

Implementation

FlatPrinter({LogConfig? config}) : config = config ?? LogConfig();