public void Log(object content, iSCDRDLogType type, bool verbose) { if (Thread.CurrentThread.Name == null) { throw new System.Exception("iSCentralDispatchRuntimeDebugger.Log cannot be called in main thread."); } iSCDThreadContainer container = GetCurrentSender(); iSCDRDLogPackage package = new iSCDRDLogPackage(container, type, content, MillisecondsSinceThreadStarted(container.iSCD_RuntimeID) * 0.001f, verbose); iSCDDebuggingThreadContainerInfo info = ContainerInfoForThreadID(container.iSCD_RuntimeID); info.logs.Add(package); lock (logPackages) logPackages.Add(package); }
void Update() { lock (logPackages) { while (logPackages.Count > 0) { if (logsThisFrame >= 50) { Debug.Log("iSCDLogger: " + logPackages.Count.ToString() + " more log left to next frame"); break; } iSCDRDLogPackage p = logPackages [0]; logPackages.RemoveAt(0); string message = FormatThreadName(p) + p.content; if (!verbose && p.isVerbose) { continue; } switch (p.type) { case iSCDRDLogType.Info: Debug.Log(message); break; case iSCDRDLogType.Warning: Debug.LogWarning(message); break; case iSCDRDLogType.Error: Debug.LogError(message); break; } logsThisFrame++; } } logsThisFrame = 0; }
string FormatThreadName(iSCDRDLogPackage p) { return(string.Format("<color=#00DFFF>{0}[{1}]({2}s): </color>", p.sender.iSCD_Name, p.sender.iSCD_RuntimeID, p.logTime.ToString("F2"))); }