Ejemplo n.º 1
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);
            }
        }