public static void Init(bool replaceLogHandler, bool logAsync, bool recordTime, string folder) { if (instance != null) { return; } var go = new GameObject("LogFile"); GameObject.DontDestroyOnLoad(go); if (logAsync) { instance = go.AddComponent <LogHandelFileAsyn>(); } else { instance = go.AddComponent <LogHandleFileSync>(); } instance.InitImpl(folder); instance.recordTime = recordTime; Application.logMessageReceived += instance.LogCallback; //是否替换LogHandler if (replaceLogHandler) { LogHandler.Init(); } }
void Log(LogType logType, string format, params object[] argst) { var text = ILogFile.LogText(logType, moduleName, format, argst); if (Application.isEditor) { LogHandler.unityLogHandler.LogFormat(logType, null, text); } }
public void LogException(Exception exception) { if ((ShowLog.Exception & showLog) != 0) { ILogFile.LogText(LogType.Exception, moduleName, exception.Message); if (Application.isEditor) { LogHandler.unityLogHandler.LogException(exception, null); } } }
/// <summary> /// /// </summary> /// <param name="replaceLogHandler"> 表示是否替换掉原生日志,打包一般需要替换,可以少写一份文件 </param> /// <param name="logAsync"> 写文件时是否使用异步方式 </param> /// <param name="recordTime"> 日志是否带上时间</param> /// <param name="folder">文件保存目录</param> public static void Init(bool replaceLogHandler, bool logAsync, bool recordTime, string logFolder) { ILogFile.Init(replaceLogHandler, logAsync, recordTime, logFolder); }
public void LogException(Exception exception, UnityEngine.Object context) { ILogFile.LogText(LogType.Exception, null, exception.Message); }
public void LogFormat(LogType logType, UnityEngine.Object context, string format, params object[] args) { ILogFile.LogText(logType, null, format, args); }