Table of Contents

Class UnityConsoleLogger

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

Implements ILogger to output log entries to the Unity Editor console. Supports Unity rich text coloring.

public class UnityConsoleLogger : ILogger, IDisposable
Inheritance
UnityConsoleLogger
Implements
Inherited Members

Constructors

UnityConsoleLogger(UnityConsoleLoggerConfig, Action<string>)

Initializes a new instance of the UnityConsoleLogger.

public UnityConsoleLogger(UnityConsoleLoggerConfig config, Action<string> internalLogCallback = null)

Parameters

config UnityConsoleLoggerConfig

Configuration for the Unity console logger.

internalLogCallback Action<string>

Optional: A callback action for internal messages from the logger itself. If null, defaults to System.Console.WriteLine.

Properties

AllowedLevels

The set of allowed log levels (read-only).

public IReadOnlyCollection<LogLevel> AllowedLevels { get; }

Property Value

IReadOnlyCollection<LogLevel>

HandlesConsoleParts

Indicates if this logger handles console parts directly (always false).

public bool HandlesConsoleParts { get; }

Property Value

bool

IsEnabled

Indicates whether this logger is enabled.

public bool IsEnabled { get; }

Property Value

bool

Methods

Dispose()

Disposes the UnityConsoleLogger. No unmanaged resources to dispose for a simple console logger.

public void Dispose()

Log(LogEntry)

Logs a structured entry to the Unity console, formatted similarly to ConsoleFormatter.

public Task Log(LogEntry entry)

Parameters

entry LogEntry

The log entry to send.

Returns

Task

A completed Task.

SetAllowedLevels(HashSet<LogLevel>)

Sets the specific log levels that this logger is allowed to process. Setting this will replace any previously configured allowed levels.

public void SetAllowedLevels(HashSet<LogLevel> levels)

Parameters

levels HashSet<LogLevel>

A HashSet containing the LogLevels to allow. If null or empty, no levels will be allowed.

SetEnabled(bool)

Sets the enabled state of the logger.

public void SetEnabled(bool enabled)

Parameters

enabled bool

True to enable, false to disable.