Table of Contents

Class UnityConsoleFormatter

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

Implements ILogger to output log entries to the Unity Editor console. Also implements IConsoleFormatter to support direct colored output via Log.WritePartsToConsole. Supports Unity rich text coloring.

public class UnityConsoleFormatter : IConsoleFormatter
Inheritance
UnityConsoleFormatter
Implements
Inherited Members

Constructors

UnityConsoleFormatter(Dictionary<LogLevel, string>, bool)

Initializes a new instance of the UnityConsoleFormatter with specified log level colors.

public UnityConsoleFormatter(Dictionary<LogLevel, string> logLevelColors, bool includeTimestamps)

Parameters

logLevelColors Dictionary<LogLevel, string>

A dictionary mapping LogLevels to Unity rich text color strings.

includeTimestamps bool

If true, timestamps will be included in the formatted output.

Methods

WriteColoredParts(LogLevel, string, int, params (string color, string text)[])

Writes a message to the Unity console composed of multiple colored parts. Implements IConsoleFormatter.WriteColoredParts.

public void WriteColoredParts(LogLevel level, string source, int columnWidth = 0, params (string color, string text)[] parts)

Parameters

level LogLevel

The log level for this message (used for a prefix, not for direct coloring of parts).

source string

The source of the log message.

columnWidth int

Optional. The minimum width for each text segment. Text will be padded if shorter. Use 0 or negative for no padding.

parts (string color, string text)[]

An array of tuples, where each tuple contains a color (hex or named) and the text for that part.

WriteStructuredLog(LogEntry)

Formats and writes a structured log entry to the Unity console, mimicking the columnar layout of ConsoleFormatter.

public void WriteStructuredLog(LogEntry entry)

Parameters

entry LogEntry

The log entry to format and write.