void HandleLog(string logString, string stackTrace, LogType type) { LogJSON j = new LogJSON(); text = ""; if (type == LogType.Assert) { j.t = "Assert"; j.l = logString; } else if (type == LogType.Exception) { j.t = "Exception"; j.l = logString; } else { int end = logString.IndexOf("]"); j.t = logString.Substring(1, end - 1); j.l = logString.Substring(end + 2); } j.s = stackTrace; if (logTime) { j.tm = System.DateTime.Now.ToString("yyyy.MM.dd.HH.mm.ss"); } fileWriter.Write((count == 0 ? "" : ",\n") + JsonUtility.ToJson(j)); count++; }
private void WriteLastLogOnFile() { LogJSON jF = new LogJSON(); jF.l = string.Format("[Warning] File: {0} reach max size", currentFile.Name); fileWriter.Write((count == 0 ? "" : ",\n") + JsonUtility.ToJson(jF)); }
internal Log(LogJSON l) { Id = l.id; Message = l.message; Timestamp = TimeSpan.FromMilliseconds(l.timestamp); Type = (LogType)l.type; }
void HandleLog(string logString, string stackTrace, LogType type) { try { LogJSON j = new LogJSON(); if (type == LogType.Assert) { j.t = "Assert"; j.l = logString; } else if (type == LogType.Exception) { j.t = "Exception"; j.l = logString; } else { int end = logString.IndexOf("]"); j.t = logString.Substring(1, end - 1); j.l = logString.Substring(end + 2); } j.s = stackTrace; j.tm = string.Format("Day {0} | Time: {1}", System.DateTime.Now.ToString("yyyy.MM.dd"), System.DateTime.Now.ToString("HH.mm.ss")); fileWriter.Write((count == 0 ? "" : ",\n") + JsonUtility.ToJson(j)); count++; if (HasFileReachMaxSize()) { WriteLastLogOnFile(); EndLogFile(); CheckFolderSize(); UpdateFilePath(); StartLogFile(); } } catch (System.Exception e) { Debug.LogError(e.Message); } }