Table of Contents

Class Log

Namespace
FishMMO.Logging
Assembly
FishMMO-Logger.dll

Manages multiple ILogger implementations, dispatching log entries to all configured loggers. This acts as the central logging hub for the application.

public static class Log
Inheritance
Log
Inherited Members

Properties

CurrentLoggingConfig

public static LoggingConfig CurrentLoggingConfig { get; }

Property Value

LoggingConfig

IncludeTimestampsInManagerLogs

Gets or sets a value indicating whether timestamps should be included in internal log messages generated by the Log manager itself (e.g., initialization status, warnings about config). This also dictates whether timestamps are shown in the UnityConsoleFormatter's output. Default is true.

public static bool IncludeTimestampsInManagerLogs { get; set; }

Property Value

bool

IsInitialized

Gets a value indicating whether the Log manager has been successfully initialized. It is considered initialized if the internal 'loggers' list is not null.

public static bool IsInitialized { get; }

Property Value

bool

OnInternalLogMessage

Callback for internal logging messages (e.g., initialization status, errors within loggers). This property's setter wraps the provided action to conditionally add a timestamp based on the IncludeTimestampsInManagerLogs setting.

public static Action<string> OnInternalLogMessage { get; set; }

Property Value

Action<string>

Methods

Critical(string, string, Exception, Dictionary<string, object>)

Writes a log message with LogLevel.Critical severity.

public static Task Critical(string source, string message, Exception exception = null, Dictionary<string, object> data = null)

Parameters

source string
message string
exception Exception
data Dictionary<string, object>

Returns

Task

Debug(string, string, Exception, Dictionary<string, object>)

Writes a log message with LogLevel.Debug severity.

public static Task Debug(string source, string message, Exception exception = null, Dictionary<string, object> data = null)

Parameters

source string
message string
exception Exception
data Dictionary<string, object>

Returns

Task

Error(string, string, Exception, Dictionary<string, object>)

Writes a log message with LogLevel.Error severity.

public static Task Error(string source, string message, Exception exception = null, Dictionary<string, object> data = null)

Parameters

source string
message string
exception Exception
data Dictionary<string, object>

Returns

Task

Info(string, string, Exception, Dictionary<string, object>)

Writes a log message with LogLevel.Info severity.

public static Task Info(string source, string message, Exception exception = null, Dictionary<string, object> data = null)

Parameters

source string
message string
exception Exception
data Dictionary<string, object>

Returns

Task

Initialize(string, IConsoleFormatter, IEnumerable<ILogger>, Action<string>, IEnumerable<Type>)

Initializes the logging system by loading configuration from a JSON file and setting up loggers.

public static Task Initialize(string configPath, IConsoleFormatter consoleFormatter = null, IEnumerable<ILogger> preExistingLoggers = null, Action<string> internalLogCallback = null, IEnumerable<Type> extraLoggerConfigTypes = null)

Parameters

configPath string

The path to the JSON configuration file.

consoleFormatter IConsoleFormatter

The formatter to use for console output. If null, a default ConsoleFormatter is used.

preExistingLoggers IEnumerable<ILogger>

Optional: A list of ILogger instances to add directly, bypassing configuration.

internalLogCallback Action<string>

Optional: A callback action for internal logging system messages (e.g., errors during initialization). If null, defaults to Console.WriteLine.

extraLoggerConfigTypes IEnumerable<Type>

Optional: Any additional ILoggerConfig types to register with the JSON converter.

Returns

Task

RegisterLoggerFactory(string, Func<ILoggerConfig, Action<string>, ILogger>)

public static void RegisterLoggerFactory(string configTypeName, Func<ILoggerConfig, Action<string>, ILogger> factory)

Parameters

configTypeName string
factory Func<ILoggerConfig, Action<string>, ILogger>

SaveConfig(LoggingConfig, string)

Saves the current logging configuration to a JSON file.

public static Task SaveConfig(LoggingConfig config, string filePath)

Parameters

config LoggingConfig

The LoggingConfig instance to save.

filePath string

The path to the JSON file where the configuration will be saved.

Returns

Task

Shutdown()

public static Task Shutdown()

Returns

Task

Verbose(string, string, Exception, Dictionary<string, object>)

Writes a log message with LogLevel.Verbose severity.

public static Task Verbose(string source, string message, Exception exception = null, Dictionary<string, object> data = null)

Parameters

source string
message string
exception Exception
data Dictionary<string, object>

Returns

Task

Warning(string, string, Exception, Dictionary<string, object>)

Writes a log message with LogLevel.Warning severity.

public static Task Warning(string source, string message, Exception exception = null, Dictionary<string, object> data = null)

Parameters

source string
message string
exception Exception
data Dictionary<string, object>

Returns

Task

Write(LogLevel, string, string, Exception, Dictionary<string, object>)

The primary entry point for all log messages. Dispatches to all configured loggers.

public static Task Write(LogLevel level, string source, string message, Exception exception = null, Dictionary<string, object> data = null)

Parameters

level LogLevel
source string
message string
exception Exception
data Dictionary<string, object>

Returns

Task

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

Writes a message to the System.Console composed of multiple colored parts using the configured formatter. This method is for arbitrary colored text, not structured columnar logs. The message is also dispatched to all registered ILoggers, excluding any logger that declares it handles console parts.

public static Task WritePartsToConsole(LogLevel level, string source, int columnWidth = 0, params (string color, string text)[] parts)

Parameters

level LogLevel

The log level for this message (used for indentation/context).

source string

The source of the log message (e.g., "Con soleOutput", "CustomDisplay").

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.

Returns

Task