Files
ShrinkNetwork/Runtime/Core/ShrinkNetworkLogger.cs
T
cneicy 8eaaa3040a
Publish UPM package / publish (push) Failing after 1s
chore: initialize standalone UPM package
2026-08-26 02:50:34 +08:00

54 lines
1.6 KiB
C#

using System;
namespace ShrinkNetwork
{
public static class ShrinkNetworkLogger
{
public static Action<string> InfoHandler { get; set; } = DefaultInfo;
public static Action<string> WarningHandler { get; set; } = DefaultWarning;
public static Action<string> ErrorHandler { get; set; } = DefaultError;
public static Action<Exception> ExceptionHandler { get; set; } = DefaultException;
public static void Info(string message) => InfoHandler?.Invoke(message);
public static void Warn(string message) => WarningHandler?.Invoke(message);
public static void Error(string message) => ErrorHandler?.Invoke(message);
public static void Exception(Exception ex) => ExceptionHandler?.Invoke(ex);
private static void DefaultInfo(string message)
{
#if UNITY_5_3_OR_NEWER
UnityEngine.Debug.Log(message);
#else
Console.WriteLine(message);
#endif
}
private static void DefaultWarning(string message)
{
#if UNITY_5_3_OR_NEWER
UnityEngine.Debug.LogWarning(message);
#else
Console.WriteLine("[Warn] " + message);
#endif
}
private static void DefaultError(string message)
{
#if UNITY_5_3_OR_NEWER
UnityEngine.Debug.LogError(message);
#else
Console.Error.WriteLine(message);
#endif
}
private static void DefaultException(Exception ex)
{
#if UNITY_5_3_OR_NEWER
UnityEngine.Debug.LogException(ex);
#else
Console.Error.WriteLine(ex);
#endif
}
}
}