2026-04-18 06:04:39 +01:00
|
|
|
using R3;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace GameCult.Logging.Unity
|
|
|
|
|
{
|
2026-04-18 13:01:24 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Adapts <see cref="ILogger"/> calls to Unity's logging facilities.
|
|
|
|
|
/// </summary>
|
2026-04-18 06:04:39 +01:00
|
|
|
public class UnityLogger : ILogger
|
|
|
|
|
{
|
|
|
|
|
private readonly bool _isDebugBuild = Debug.isDebugBuild; // Cache Unity-specific
|
|
|
|
|
|
2026-04-18 13:01:24 +01:00
|
|
|
/// <inheritdoc />
|
2026-04-18 06:04:39 +01:00
|
|
|
public void LogInfo(string message)
|
|
|
|
|
{
|
|
|
|
|
Observable.NextFrame().Subscribe(_ => Debug.Log($"[INFO] {message}"));
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-18 13:01:24 +01:00
|
|
|
/// <inheritdoc />
|
2026-04-18 06:04:39 +01:00
|
|
|
public void LogWarning(string message)
|
|
|
|
|
{
|
|
|
|
|
Observable.NextFrame().Subscribe(_ => Debug.LogWarning($"[WARN] {message}"));
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-18 13:01:24 +01:00
|
|
|
/// <inheritdoc />
|
2026-04-18 06:04:39 +01:00
|
|
|
public void LogError(string message)
|
|
|
|
|
{
|
|
|
|
|
Observable.NextFrame().Subscribe(_ => Debug.LogError($"[ERROR] {message}"));
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-18 13:01:24 +01:00
|
|
|
/// <inheritdoc />
|
2026-04-18 06:04:39 +01:00
|
|
|
public void LogDebug(string message)
|
|
|
|
|
{
|
|
|
|
|
if (_isDebugBuild)
|
|
|
|
|
Observable.NextFrame().Subscribe(_ => Debug.Log($"[DEBUG] {message}"));
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-04-18 13:01:24 +01:00
|
|
|
}
|