Class UnityConsoleLog
An ILogReceiver implementation that routes Scylla log output to the Unity built-in console. Each log entry is assembled into a single string and dispatched through the appropriate Unity logging method based on its severity level.
Implements
Inherited Members
Namespace: Scylla.Core
Assembly: ScyllaCore.dll
Syntax
public sealed class UnityConsoleLog : ILogReceiver
Remarks
Log-level mapping:
-
System, Trace,
Debug, Info,
Notice, and Minimum all map to
UnityEngine.Debug.Log. -
Warning maps to
UnityEngine.Debug.LogWarning. -
Error, Fatal, and
Maximum map to
UnityEngine.Debug.LogError.
Allocation strategy: Message strings are built using a
[ThreadStatic] StringBuilder (_stringBuilder) that is
lazy-initialized per thread, eliminating per-call heap allocations and lock contention.
Display of individual metadata fields (timestamp, code location, prefix, label, category)
is controlled by the Show* properties. Default settings match those defined in
ConsoleLoggingSettings.
Constructors
UnityConsoleLog()
Initializes a new UnityConsoleLog with all display options set to their built-in defaults: prefix, label, and category enabled; timestamp and code location disabled.
Declaration
public UnityConsoleLog()
UnityConsoleLog(ConsoleLoggingSettings)
Initializes a new UnityConsoleLog using the display options from the supplied
ConsoleLoggingSettings asset. Each Show* property on this instance is
set from the corresponding field on settings.
Declaration
public UnityConsoleLog(ConsoleLoggingSettings settings)
Parameters
| Type | Name | Description |
|---|---|---|
| ConsoleLoggingSettings | settings | The console logging settings to apply. If |
Properties
LogLabelLevel
Gets the minimum LogLevel at which the descriptive level label (e.g.
[DEBUG], [WARNING]) is included in the Unity console output. This
implementation returns Minimum, meaning labels are always emitted
regardless of severity, giving the console the richest possible context for every entry.
Declaration
public LogLevel LogLabelLevel { get; }
Property Value
| Type | Description |
|---|---|
| LogLevel | Minimum, so labels are included for all log levels. |
LogPrefix
Gets the prefix string that prepends all log messages in the Unity console output.
Returns LOG_PREFIX, which wraps the Scylla short name in square brackets
(e.g. [Scylla]), making Scylla messages immediately identifiable in the Unity console.
Declaration
public string LogPrefix { get; }
Property Value
| Type | Description |
|---|---|
| string | The constant prefix string defined by LOG_PREFIX. |
ShowCategory
Gets or sets whether the padded log category (e.g. [Core]) is included in each log
line in the Unity console output.
Declaration
public bool ShowCategory { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
|
ShowCodeLocation
Gets or sets whether the source file name and line number are prepended to each log line in the Unity console output.
Declaration
public bool ShowCodeLocation { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
|
ShowLabel
Gets or sets whether the padded log-level label (e.g. [WARNING]) is included in
each log line in the Unity console output.
Declaration
public bool ShowLabel { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
|
ShowPrefix
Gets or sets whether the log prefix (e.g. [Scylla]) is prepended to each log line in
the Unity console output.
Declaration
public bool ShowPrefix { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
|
ShowTimestamp
Gets or sets whether a timestamp is prepended to each log line in the Unity console output.
Declaration
public bool ShowTimestamp { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
|
Methods
ClearLog()
Clears all log entries in the Unity Editor console.
Declaration
public void ClearLog()
Remarks
This method uses Unity's internal UnityEditorInternal.LogEntries.Reset API to
reset the console. It is functional only inside the Unity Editor; in a player build there
is no editor console to clear, so the method returns immediately.
The editor API is reached entirely through string-based reflection (the UnityEditor
assembly is located by name, never referenced by type). This is deliberate: it keeps this
runtime assembly free of any compile-time dependency on UnityEditor.dll, so the
shipped runtime DLL loads cleanly in player builds instead of being rejected with
"UnityEditor.dll assembly is referenced by user code." A UnityEngine.Application.isEditor
guard short-circuits the reflection in players.
LogData(LogEntry)
Assembles the enabled metadata fields from logEntry into a single string
and writes it to the Unity built-in console using the Unity Debug API method that
corresponds to the entry's severity level.
Declaration
public void LogData(LogEntry logEntry)
Parameters
| Type | Name | Description |
|---|---|---|
| LogEntry | logEntry | The pre-formatted log entry containing all components. Only the fields enabled by the
|
Remarks
Level-to-method mapping:
-
System, Trace,
Debug, Info,
Notice, Minimum, and any
unrecognised value →
UnityEngine.Debug.Log. -
Warning →
UnityEngine.Debug.LogWarning. -
Error, Fatal,
Maximum →
UnityEngine.Debug.LogError.
The per-thread _stringBuilder is lazy-initialized on the first call from each
thread and reused thereafter to avoid heap allocations in the hot path.