LogCommons class final

A utility class that provides common styling and symbols for different LogLevels.

The LogCommons class is designed to aid in formatting and visualizing log output in the console or terminal, particularly during development or debugging. It maps log severity levels to ANSI color codes and emoji icons for enhanced readability.

This class cannot be instantiated and is intended to be used statically.

Example usage:

final emoji = LogCommons.levelEmojis[LogLevel.error]; // ❌
final color = LogCommons.levelColors[LogLevel.info];  // Green text color (ANSI)
print('${color.wrap("$emoji Info message")}');

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

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

Static Properties

levelColors Map<LogLevel, AnsiColor>
A mapping between LogLevels and their associated ANSI foreground color.
final
levelEmojis Map<LogLevel, String>
A mapping between LogLevels and their associated emoji icon.
final

Static Methods

extractCallerLocation([int frameLevel = 2]) String?
formatElapsed(Duration elapsed) String
Formats a duration in a human-readable format.
formatTimestamp(DateTime time, bool humanReadable) String
Formats a timestamp based on the specified format.