protected virtual bool FormatChannel(StringBuilder stringBuilder, DetailedLog log)
 {
     stringBuilder.Append('[');
     stringBuilder.Append(ColorExtensions.ColorText(log.Channel.name, Color.cyan));
     stringBuilder.Append(']');
     return(true);
 }
示例#2
0
        protected override ILog ConstructDebugLog(string condition, string stackTrace, LogType type, bool prependTimeStamp, bool appendStackTrace)
        {
            if (Theme)
            {
                switch (type)
                {
                case LogType.Warning:
                {
                    condition = ColorExtensions.ColorText(condition, Theme.WarningColor);
                    break;
                }

                case LogType.Error:
                case LogType.Assert:
                case LogType.Exception:
                {
                    condition = ColorExtensions.ColorText(condition, Theme.ErrorColor);
                    break;
                }
                }
            }

            return(new DetailedLog(condition, true)
            {
                Type = type,
                StackTrace = appendStackTrace ? stackTrace : null,
#if CHIRP
                Channel = "Unity"
#endif
            });
        }
示例#3
0
 private string FormatTrace(string logTrace)
 {
     if (_theme)
     {
         if (logTrace.ContainsCaseInsensitive("error"))
         {
             return(ColorExtensions.ColorText(logTrace, _theme.ErrorColor));
         }
         else if (logTrace.ContainsCaseInsensitive("warning"))
         {
             return(ColorExtensions.ColorText(logTrace, _theme.WarningColor));
         }
         else if (logTrace.ContainsCaseInsensitive("success"))
         {
             return(ColorExtensions.ColorText(logTrace, _theme.SuccessColor));
         }
         else
         {
             return(logTrace);
         }
     }
     else
     {
         return(logTrace);
     }
 }
示例#4
0
        private void SetCommandSuggestion(CommandData command)
        {
            OverrideConsoleInput(command.CommandName);
            Color suggestionColor = _theme ? _theme.SuggestionColor : Color.gray;

            _consoleSuggestionText.text = $"{ColorExtensions.ColorText(command.CommandName, Color.clear)}{ColorExtensions.ColorText(command.GenericSignature, suggestionColor)} {ColorExtensions.ColorText(command.ParameterSignature, suggestionColor)}";
        }
        protected virtual bool FormatRepeatCount(StringBuilder stringBuilder, DetailedLog log)
        {
            if (log.RepeatCount <= 0)
            {
                return(false);
            }

            stringBuilder.Append('[');
            stringBuilder.Append(ColorExtensions.ColorText((log.RepeatCount + 1).ToString(), Color.cyan));
            stringBuilder.Append(']');

            return(true);
        }
示例#6
0
        private string GetTableGenerationText()
        {
            string text = $"Q:\\>Quantum Console Processor is initialising";

            text += $"\nQ:\\>Table generation under progress";
            text += $"\nQ:\\>{QuantumConsoleProcessor.LoadedCommandCount} commands have been loaded";
            if (QuantumConsoleProcessor.TableIsGenerating)
            {
                text += "...";
            }
            else
            {
                text += ColorExtensions.ColorText($"\nQ:\\>Quantum Console Processor ready", _theme ? _theme.SuccessColor : Color.white);
            }

            return(text);
        }
        public static string WrapTextColorByLevel(string text, LogType level, QuantumTheme theme)
        {
            if (theme == null)
            {
                return(text);
            }

            if (level == LogType.Warning)
            {
                return(ColorExtensions.ColorText(text, theme.WarningColor));
            }

            if (level == LogType.Assert || level == LogType.Error || level == LogType.Exception)
            {
                return(ColorExtensions.ColorText(text, theme.ErrorColor));
            }

            return(text);
        }
示例#8
0
        private void DebugIntercept(string condition, string stackTrace, LogType type)
        {
            if (_interceptDebugLogger && (IsActive || _interceptWhilstInactive) && _loggingLevel >= type.ToLoggingThreshold())
            {
                if (_prependTimestamps)
                {
                    DateTime now    = DateTime.Now;
                    string   format = _theme
                        ? _theme.TimestampFormat
                        : "[{0}:{1}:{2}]";

                    condition = $"{string.Format(format, now.Hour, now.Minute, now.Second)} {condition}";
                }

                if (_theme)
                {
                    switch (type)
                    {
                    case LogType.Log:
                    {
                        if (_verboseLogging >= LoggingThreshold.Always)
                        {
                            condition += $"\n{stackTrace}";
                        }
                        break;
                    }

                    case LogType.Warning:
                    {
                        if (_verboseLogging >= LoggingThreshold.Warning)
                        {
                            condition += $"\n{stackTrace}";
                        }
                        condition = ColorExtensions.ColorText(condition, _theme.WarningColor);
                        break;
                    }

                    case LogType.Error:
                    {
                        if (_verboseLogging >= LoggingThreshold.Error)
                        {
                            condition += $"\n{stackTrace}";
                        }
                        condition = ColorExtensions.ColorText(condition, _theme.ErrorColor);
                        break;
                    }

                    case LogType.Assert:
                    {
                        if (_verboseLogging >= LoggingThreshold.Error)
                        {
                            condition += $"\n{stackTrace}";
                        }
                        condition = ColorExtensions.ColorText(condition, _theme.ErrorColor);
                        break;
                    }

                    case LogType.Exception:
                    {
                        if (_verboseLogging >= LoggingThreshold.Exception)
                        {
                            condition += $"\n{stackTrace}";
                        }
                        condition = ColorExtensions.ColorText(condition, _theme.ErrorColor);
                        break;
                    }
                    }
                }

                LogToConsoleAsync(condition, type);
            }
        }