mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-12 22:10:11 -05:00
とりあえず ILogHandler に対応。更なる拡張は使うときに。
This commit is contained in:
@@ -4,8 +4,55 @@ namespace UniGLTF
|
||||
{
|
||||
public static class UniGLTFLogger
|
||||
{
|
||||
class DefaultUnityLogger : ILogHandler
|
||||
{
|
||||
public void LogException(System.Exception exception, UnityEngine.Object context)
|
||||
{
|
||||
Debug.LogException(exception, context);
|
||||
}
|
||||
|
||||
public void LogFormat(LogType logType, UnityEngine.Object context, string format, params object[] args)
|
||||
{
|
||||
switch (logType)
|
||||
{
|
||||
case LogType.Error:
|
||||
Debug.LogError(string.Format(format, args), context);
|
||||
break;
|
||||
case LogType.Assert:
|
||||
Debug.LogAssertion(string.Format(format, args), context);
|
||||
break;
|
||||
case LogType.Warning:
|
||||
Debug.LogWarning(string.Format(format, args), context);
|
||||
break;
|
||||
case LogType.Log:
|
||||
Debug.Log(string.Format(format, args), context);
|
||||
break;
|
||||
case LogType.Exception:
|
||||
// where exception ?
|
||||
Debug.LogError(string.Format(format, args), context);
|
||||
break;
|
||||
default:
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static ILogHandler s_logger = new DefaultUnityLogger();
|
||||
|
||||
public static void SetLogger(ILogHandler logger)
|
||||
{
|
||||
if (logger != null)
|
||||
{
|
||||
s_logger = logger;
|
||||
}
|
||||
else
|
||||
{
|
||||
s_logger = new DefaultUnityLogger();
|
||||
}
|
||||
}
|
||||
|
||||
[System.Diagnostics.Conditional("VRM_DEVELOP")]
|
||||
[HideInCallstack]
|
||||
public static void Log(string msg) => Debug.Log(msg);
|
||||
public static void Log(string msg, UnityEngine.Object context = null) => s_logger.LogFormat(LogType.Log, context, msg);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user