/// <summary> /// Creates a log with multiple ategories for the msg provided /// </summary> /// <param name="categories">The multiple categories</param> /// <param name="severityLevel">THe severity of this log</param> /// <param name="msg">Message that will be logged</param> /// <param name="args">Objects that will be formatted into the msg is need be</param> public virtual void LogWithCategories(List <string> categories, LogType severityLevel, string msg, params object[] args) { //If none of the ategories are active, skip this log if (!IsAnyCategoryActive(categories.ToArray())) { return; } StackTrace stack = new StackTrace(1, true); sLogInfo newLogInfo = new sLogInfo(); newLogInfo.Message = string.Format(msg, args); newLogInfo.Timestamp = UnityEngine.Time.time.ToString(); newLogInfo.StackInfo = CreateInfoLine(stack); newLogInfo.Categories = categories.ToArray(); newLogInfo.SeverityLevel = severityLevel; ProcessLog(newLogInfo, stack); }
protected virtual void ProcessLog(sLogInfo logInfo, StackTrace stackInfo) { m_AllLogs.Add(logInfo); string logString = logInfo.Message + logInfo.StackInfo + logInfo.FormatCategories() + FormatStackTrace(stackInfo); // Don't know if I'll keep this around for ever... This is just used to be able to visualize the logs that are making it through the category filter if (IsLoggingToConsole) { // Do a proper Debug log based off the severity level if (logInfo.SeverityLevel == LogType.Error || logInfo.SeverityLevel == LogType.Exception) { UnityEngine.Debug.LogError(logString); } else if (logInfo.SeverityLevel == LogType.Warning) { UnityEngine.Debug.LogWarning(logString); } else { UnityEngine.Debug.Log(logString); } } }
/// <summary> /// Creates a log with multiple ategories for the msg provided /// </summary> /// <param name="categories">The multiple categories</param> /// <param name="severityLevel">THe severity of this log</param> /// <param name="msg">Message that will be logged</param> /// <param name="args">Objects that will be formatted into the msg is need be</param> public virtual void LogWithCategories(List<string> categories, LogType severityLevel, string msg, params object[] args) { //If none of the ategories are active, skip this log if (!IsAnyCategoryActive(categories.ToArray())) { return; } StackTrace stack = new StackTrace(1, true); sLogInfo newLogInfo = new sLogInfo(); newLogInfo.Message = string.Format(msg, args); newLogInfo.Timestamp = UnityEngine.Time.time.ToString(); newLogInfo.StackInfo = CreateInfoLine(stack); newLogInfo.Categories = categories.ToArray(); newLogInfo.SeverityLevel = severityLevel; ProcessLog(newLogInfo, stack); }