Class UnityConsoleLogger
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
configUnityConsoleLoggerConfigConfiguration for the Unity console logger.
internalLogCallbackAction<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
HandlesConsoleParts
Indicates if this logger handles console parts directly (always false).
public bool HandlesConsoleParts { get; }
Property Value
IsEnabled
Indicates whether this logger is enabled.
public bool IsEnabled { get; }
Property Value
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
entryLogEntryThe 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
levelsHashSet<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
enabledboolTrue to enable, false to disable.