Files
SpacetimeDB/src/UnityDebugLogger.cs
T
Ingvar Stepanyan 596c4a5e5c Make logger a separate SDK setting from client instance (#79)
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.
2024-04-24 17:51:53 +01:00

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