Table of Contents

Class ConsoleFormatterHelpers

Namespace
FishMMO.Logging
Assembly
FishMMO-Logger.dll

Provides shared helper methods and constants for console formatting, used by both ConsoleFormatter and UnityConsoleFormatter to ensure consistent output.

public static class ConsoleFormatterHelpers
Inheritance
ConsoleFormatterHelpers
Inherited Members

Fields

ConsoleColorRgbMap

public static readonly Dictionary<ConsoleColor, (byte r, byte g, byte b)> ConsoleColorRgbMap

Field Value

Dictionary<ConsoleColor, (byte r, byte g, byte b)>

LogLevelColumnWidth

public const int LogLevelColumnWidth = 12

Field Value

int

SourceColumnWidth

public const int SourceColumnWidth = 18

Field Value

int

TimestampColumnWidth

public const int TimestampColumnWidth = 12

Field Value

int

Methods

EscapeUnityRichText(string)

Escapes characters in a string that might be interpreted as Unity rich text tags. This prevents malformed tags from breaking the console output. This method is specific to Unity's rich text, but is placed here for shared access.

public static string EscapeUnityRichText(string text)

Parameters

text string

The text to escape.

Returns

string

The escaped text.

FindClosestConsoleColor((byte r, byte g, byte b))

Finds the closest System.ConsoleColor to a given RGB tuple using Euclidean distance.

public static ConsoleColor FindClosestConsoleColor((byte r, byte g, byte b) targetRgb)

Parameters

targetRgb (byte r, byte g, byte b)

Returns

ConsoleColor

GetClosestConsoleColor(string)

Converts a hex color string or named color to the closest System.ConsoleColor.

public static ConsoleColor GetClosestConsoleColor(string color)

Parameters

color string

Returns

ConsoleColor

GetSourceColor(string, LogLevel)

Gets a specific color for the log source (e.g., Daemon, Orchestration, App Name) or applies a default color based on the LogLevel if no specific source matches.

public static ConsoleColor GetSourceColor(string source, LogLevel level)

Parameters

source string
level LogLevel

Returns

ConsoleColor

PadRight(string, int)

Pads a string to a specified total width.

public static string PadRight(string text, int totalWidth)

Parameters

text string

The string to pad.

totalWidth int

The total width of the resulting string.

Returns

string

The padded string.