protected void OnEntryAdded(ConsoleEntry entry)
        {
            if (_hasCleared)
            {
                _consoleEntries.Add(entry);
            }

            _allConsoleEntries.Add(entry);

            OnUpdated();
        }
        protected void OnEntryDuplicated(ConsoleEntry entry)
        {
            entry.Count++;

            OnUpdated();

            // If has cleared, add this entry again for the current list
            if (_hasCleared && _consoleEntries.Count == 0)
            {
                OnEntryAdded(new ConsoleEntry(entry) {Count = 1});
            }
        }
Exemplo n.º 3
0
        private void PopulateStackTraceArea(ConsoleEntry entry)
        {
            if (entry == null)
            {
                StackTraceText.text = "";
            }
            else
            {
                var text = entry.Message + Environment.NewLine +
                           (!string.IsNullOrEmpty(entry.StackTrace)
                                                                  ? entry.StackTrace
                                                                  : SRDebugStrings.Current.Console_NoStackTrace);

                if (text.Length > MaxLength)
                {
                    text  = text.Substring(0, MaxLength);
                    text += "\n" + SRDebugStrings.Current.Console_MessageTruncated;
                }

                StackTraceText.text = text;
            }

            StackTraceScrollRect.normalizedPosition = Vector2.zero;
        }
Exemplo n.º 4
0
        private bool RconCommand(Match match)
        {
            var address = match.Groups[1].Value;
            var message = match.Groups[2].Value;

            if (IgnoreStatus && message == "status")
            {
                return(true);
            }

            var newEntry = new ConsoleEntry()
            {
                Contents  = message,
                Source    = "RCON/" + address,
                SourceId  = "RCON/" + address,
                Type      = "Console",
                Timestamp = DateTime.Now
            };

            AddConsoleEntry(newEntry);
            module.log.ConsoleOutput(match.Value);

            return(true);
        }
        private void UnityLogCallback(string condition, string stackTrace, LogType type)
        {
            //if (condition.StartsWith("[SRConsole]"))
            //    return;

            var prevMessage = _collapseEnabled && _allConsoleEntries.Count > 0
                ? _allConsoleEntries[_allConsoleEntries.Count - 1]
                : null;

            if (prevMessage != null && prevMessage.LogType == type && prevMessage.Message == condition &&
                prevMessage.StackTrace == stackTrace)
            {
                OnEntryDuplicated(prevMessage);
            }
            else
            {
                var newEntry = new ConsoleEntry
                {
                    LogType = type,
                    StackTrace = stackTrace,
                    Message = condition
                };

                OnEntryAdded(newEntry);
            }

            switch (type)
            {
                case LogType.Assert:
                case LogType.Error:
                case LogType.Exception:
                    ErrorCount++;
                    break;

                case LogType.Warning:
                    WarningCount++;
                    break;

                case LogType.Log:
                    InfoCount++;
                    break;
            }
        }
Exemplo n.º 6
0
        private void LogInternal(ConsoleEntry consoleEntry)
        {
            if (_log.Count > 0)
            {
                var last = _log[_log.Count - 1];

                if (last.Name != string.Empty && last.Name == consoleEntry.Name && last.Message == consoleEntry.Message)
                {
                    last.Count++;
                }
                else
                {
                    _log.Add(consoleEntry);
                }
            }
            else
            {
                _log.Add(consoleEntry);
            }
        }
Exemplo n.º 7
0
        public void SetDataContext(object data)
        {
            var msg = data as ConsoleEntry;

            if (msg == null)
            {
                throw new Exception("Data should be a ConsoleEntry");
            }

            // Always check for updates on "Count", as it can change
            if (msg.Count > 1)
            {
                if (!_hasCount)
                {
                    CountContainer.alpha = 1f;
                    _hasCount            = true;
                }

                if (msg.Count != _count)
                {
                    Count.text = Internal.SRDebuggerUtil.GetNumberString(msg.Count, 999, "999+");
                    _count     = msg.Count;
                }
            }
            else if (_hasCount)
            {
                CountContainer.alpha = 0f;
                _hasCount            = false;
            }

            // Only update everything else if data context has changed, not just for an update
            if (msg == _prevData)
            {
                return;
            }

            _prevData = msg;

            Message.text    = msg.MessagePreview;
            StackTrace.text = msg.StackTracePreview;

            if (string.IsNullOrEmpty(StackTrace.text))
            {
                Message.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Bottom, 2,
                                                                    _rectTransform.rect.height - 4);
            }
            else
            {
                Message.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Bottom, 12,
                                                                    _rectTransform.rect.height - 14);
            }

            switch (msg.LogType)
            {
            case LogType.Log:
                ImageStyle.StyleKey = ConsoleBlobInfo;
                break;

            case LogType.Warning:
                ImageStyle.StyleKey = ConsoleBlobWarning;
                break;

            case LogType.Exception:
            case LogType.Assert:
            case LogType.Error:
                ImageStyle.StyleKey = ConsoleBlobError;
                break;
            }
        }