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
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
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
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
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
Returns
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
Returns
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
Returns
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
Returns
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
configPathstringThe path to the JSON configuration file.
consoleFormatterIConsoleFormatterThe formatter to use for console output. If null, a default ConsoleFormatter is used.
preExistingLoggersIEnumerable<ILogger>Optional: A list of ILogger instances to add directly, bypassing configuration.
internalLogCallbackAction<string>Optional: A callback action for internal logging system messages (e.g., errors during initialization). If null, defaults to Console.WriteLine.
extraLoggerConfigTypesIEnumerable<Type>Optional: Any additional ILoggerConfig types to register with the JSON converter.
Returns
RegisterLoggerFactory(string, Func<ILoggerConfig, Action<string>, ILogger>)
public static void RegisterLoggerFactory(string configTypeName, Func<ILoggerConfig, Action<string>, ILogger> factory)
Parameters
SaveConfig(LoggingConfig, string)
Saves the current logging configuration to a JSON file.
public static Task SaveConfig(LoggingConfig config, string filePath)
Parameters
configLoggingConfigThe LoggingConfig instance to save.
filePathstringThe path to the JSON file where the configuration will be saved.
Returns
Shutdown()
public static Task Shutdown()
Returns
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
Returns
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
Returns
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
Returns
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
levelLogLevelThe log level for this message (used for indentation/context).
sourcestringThe source of the log message (e.g., "Con soleOutput", "CustomDisplay").
columnWidthintOptional. 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.