Slua Logger log callback
@@ -8,18 +8,39 @@ namespace SLua
/// <summary>
/// A bridge between UnityEngine.Debug.LogXXX and standalone.LogXXX
/// </summary>
- internal class Logger
+ public class Logger
{
+ public enum Level
+ {
+ Debug,
+ Warning,
+ Error
+ }
+ public static Action<Level, string> LogAction;
+
public static void Log(string msg)
{
+ if (LogAction != null)
+ {
+ LogAction(Level.Debug, msg);
+ return;
+ }
+
#if !SLUA_STANDALONE
UnityEngine.Debug.Log(msg);
#else
Console.WriteLine(msg);
#endif
}
+
public static void LogError(string msg)
{
+ if (LogAction != null)
+ {
+ LogAction(Level.Error, msg);
+ return;
+ }
+
#if !SLUA_STANDALONE
UnityEngine.Debug.LogError(msg);
#else
@@ -29,6 +50,12 @@ namespace SLua
public static void LogWarning(string msg)
{
+ if (LogAction != null)
+ {
+ LogAction(Level.Warning, msg);
+ return;
+ }
+
#if !SLUA_STANDALONE
UnityEngine.Debug.LogWarning(msg);
#else
