PrettyLogFormatter class

A formatter that outputs log messages with ANSI colors for terminal display.

This formatter produces human-readable output with color-coded components for improved readability in terminal environments. Each log level has its own color scheme:

  • DEBUG - Blue
  • INFO - Green
  • NOTICE - Cyan
  • WARNING - Yellow
  • ERROR - Red
  • ALERT/EMERGENCY - Bold Red

The output format is logfmt-style key/value pairs with colors:

time="2024-02-15T10:30:45.123-05:00" level=info msg="Message" key=value

Components:

  • Keys - Gray
  • Timestamp - Gray
  • Log Level - Level-specific color
  • Prefix - Cyan (if present)
  • Message - Default terminal color
  • Context Keys - Magenta (if present)

Note: This formatter requires a terminal that supports ANSI color codes. Colors may not display correctly in all environments.

Inheritance

Constructors

PrettyLogFormatter({FormatterSettings? settings})
Creates a pretty formatter with the default color scheme.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
settings FormatterSettings
Configuration settings that control formatting behavior.
finalinherited

Methods

format(LogRecord record) String
Converts a log record into a formatted string.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited