PrettyPrinter class final

A visually styled log printer that wraps log output in a clean box format.

This printer improves readability during development by using Unicode borders, emoji icons (optional), and structured multi-line formatting. It is useful for console applications, CLI tools, or Flutter/Dart debug output.

Example Output:

┌──────────────────────────────────────────────────────────────────────────────
│ 💬 MESSAGE: User signed in
│ ⏰ TIME: 2025-06-23 10:20:01.235
│ 🏷️ TAG: AuthService
├──────────────────────────────────────────────────────────────────────────────
│ ❌ ERROR: Missing token
│ 📋 STACK:
│ #0 AuthService.login (auth_service.dart:42)
│ #1 ...
└──────────────────────────────────────────────────────────────────────────────

Configuration is controlled via LogConfig, and log content is selected based on LogStep order.

Inheritance

Constructors

PrettyPrinter({int methodCount = 2, int errorMethodCount = 8, int lineLength = 120, LogConfig? config, int stackTraceBeginIndex = 0, List<String>? excludePaths})

Properties

config LogConfig
Configuration for the printer
final
errorMethodCount int
Number of stack trace lines to show for error logs
final
excludePaths List<String>
List of paths to exclude from stack traces
final
hashCode int
The hash code for this object.
no setterinherited
lineLength int
Maximum line length for the log output
final
methodCount int
Number of stack trace lines to show for normal logs
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stackTraceBeginIndex int
Index to start from in the stack trace
final

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

Constants

bottomLeftCorner → const String
doubleDivider → const String
middleCorner → const String
singleDivider → const String
topLeftCorner → const String
verticalLine → const String