Example #1
0
        private void AddLog(string logString, string stacktrace, LogType type)
        {
            if (this.maxLines == 0)
            {
                return;
            }

            m_GoToBottom = m_ScrollRect.verticalNormalizedPosition == 0;

            if (this.maxLines > 0 && m_LogEntries.Count + 1 > this.maxLines)
            {
                DebugLogEntry entry = m_LogEntries[0];
                m_LogEntries.RemoveAt(0);
                entry.ReturnToPool();
                entry.transform.SetParent(m_LogEntryPool);
            }

            DebugLogEntry newLog = null;

            if (string.IsNullOrEmpty(stacktrace))
            {
                if (m_LogPool.Count == 0)
                {
                    m_LogPool.IncreasePool(10);
                }
                newLog = m_LogPool.GetObject();
            }
            else
            {
                if (m_LogWithStackPool.Count == 0)
                {
                    m_LogWithStackPool.IncreasePool(10);
                }
                newLog = m_LogWithStackPool.GetObject();
            }

            newLog.gameObject.SetActive(true);
            newLog.transform.SetParent(m_LogContent.transform);
            newLog.transform.SetSiblingIndex(newLog.transform.parent.childCount - 1);
            newLog.SetText(logString, stacktrace, type);

            m_LogEntries.Add(newLog);

            if (type == LogType.Log)
            {
                buttonFilterLogs.transform.Find("Text").GetComponent <Text>().text = m_LogEntries.FindAll(i => i.LogType == type).Count.ToString();
            }
            else if (type == LogType.Warning)
            {
                buttonFilterWarnings.transform.Find("Text").GetComponent <Text>().text = m_LogEntries.FindAll(i => i.LogType == type).Count.ToString();
            }
            else if (type == LogType.Error)
            {
                buttonFilterErrors.transform.Find("Text").GetComponent <Text>().text = m_LogEntries.FindAll(i => i.LogType == LogType.Assert || i.LogType == LogType.Error || i.LogType == LogType.Exception).Count.ToString();
            }
        }
Example #2
0
 /// <summary>
 /// Function to return if a DebugLogEntry is currently being used as a
 /// log entry by any logs.  Used by the pool to determine if a entry can be used.
 /// (Inactive entries may merely be off because they are filtered for display.)
 /// </summary>
 /// <param name="entry">The entry to check for current use.</param>
 public static bool IsLogEntryInUse(DebugLogEntry entry)
 {
     foreach (DebugLog log in s_DebugOutputs)
     {
         if (log.m_LogEntries.Contains(entry))
         {
             return(true);
         }
     }
     return(false);
 }