54 lines
1.6 KiB
C#
54 lines
1.6 KiB
C#
using System;
|
|
|
|
namespace ShrinkCommand
|
|
{
|
|
public static class ShrinkCommandLogger
|
|
{
|
|
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
|
|
}
|
|
}
|
|
}
|