mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-05-15 04:08:02 -04:00
596c4a5e5c
This allows to: 1. Have a preset logger that is already correctly matching the environment (console vs Unity). 2. Removes the need for explicit `SpacetimeDBClient.CreateInstance(...)` which is particularly awkward to use and easy to forget with singleton as it doesn't return a result as a factory method name could suggest. Instead, `SpacetimeDBClient.instance` is available on first use. 3. Slightly simplifies dependencies between classes, e.g. `ClientCache` doesn't need a circular dependency on `SpacetimeDBClient`, making future maintenance and changes a bit easier.
35 lines
692 B
C#
35 lines
692 B
C#
/* SpacetimeDB logging for Unity
|
|
* * This class is only used in Unity projects.
|
|
* *
|
|
*/
|
|
#if UNITY_5_3_OR_NEWER
|
|
using System;
|
|
using UnityEngine;
|
|
|
|
namespace SpacetimeDB
|
|
{
|
|
public class UnityDebugLogger : ISpacetimeDBLogger
|
|
{
|
|
public void Log(string message)
|
|
{
|
|
Debug.Log(message);
|
|
}
|
|
|
|
public void LogError(string message)
|
|
{
|
|
Debug.LogError(message);
|
|
}
|
|
|
|
public void LogException(Exception e)
|
|
{
|
|
Debug.LogException(e);
|
|
}
|
|
|
|
public void LogWarning(string message)
|
|
{
|
|
Debug.LogWarning(message);
|
|
}
|
|
}
|
|
}
|
|
#endif
|