// Write a string on new line public void WriteLine(string msg) { if (m_enabled) { lock (m_lock) { WriteDateTimeAndThreadId(); WriteString(msg); m_streamWriter.WriteLine(); m_streamWriter.Flush(); } } if (LogForMemoryProfiler) { MyMemoryLogs.AddConsoleLine(msg); } //Debug.WriteLine(msg); }
public void IncreaseIndent() { if (m_enabled == false) { return; } lock (m_lock) { int threadId = GetThreadId(); m_indentsByThread[threadId] = GetIdentByThread(threadId) + 1; MyLogIndentKey indentKey = new MyLogIndentKey(threadId, m_indentsByThread[threadId]); m_indents[indentKey] = new MyLogIndentValue(GetManagedMemory(), GetSystemMemory(), DateTimeOffset.Now); if (LogForMemoryProfiler) { MyMemoryLogs.StartEvent(); } } }
public void DecreaseIndent() { if (m_enabled == false) { return; } MyLogIndentValue indentValue; lock (m_lock) { int threadId = GetThreadId(); MyLogIndentKey indentKey = new MyLogIndentKey(threadId, GetIdentByThread(threadId)); // If this fails, then order of IncreaseIndent/DecreaseIndent was wrong, or duplicate, etc MyDebug.AssertDebug(m_indents.ContainsKey(indentKey)); indentValue = m_indents[indentKey]; if (LogForMemoryProfiler) { MyMemoryLogs.MyMemoryEvent memEvent = new MyMemoryLogs.MyMemoryEvent(); memEvent.DeltaTime = (float)(DateTimeOffset.Now - indentValue.LastDateTimeOffset).TotalMilliseconds / 1000.0f; memEvent.ManagedEndSize = GetManagedMemory(); memEvent.ProcessEndSize = GetSystemMemory(); memEvent.ManagedStartSize = indentValue.LastGcTotalMemory; memEvent.ProcessStartSize = indentValue.LastWorkingSet; MyMemoryLogs.EndEvent(memEvent); } } lock (m_lock) { int threadId = GetThreadId(); m_indentsByThread[threadId] = GetIdentByThread(threadId) - 1; } }