Beispiel #1
0
        private static void Print(EventWrap data)
        {
            var fColor = Console.ForegroundColor;
            var bColor = Console.BackgroundColor;

            PrintInt(data);

            SetConsoleColors(fColor, bColor);
        }
Beispiel #2
0
 private static void Hydrate(EventWrap data)
 {
     if (string.IsNullOrWhiteSpace(data.ProcessName))
     {
         using (var process = Process.GetProcessById(data.ProcessID))
         {
             //data.ProcessName = process.ProcessName;
             data.ProcessName = process.MainModule?.ModuleName;
         }
     }
 }
Beispiel #3
0
        private static void OnClrOnExceptionStart(ExceptionTraceData data)
        {
            var @event = new EventWrap(data);

            Hydrate(@event);

            if (_outputEnabled)
            {
                Print(@event);
            }
            else
            {
                _buffer.Enqueue(@event);
            }
        }
Beispiel #4
0
        private static void PrintInt(EventWrap data)
        {
            var dataAsStr = data.ToString();

            foreach (var filter in _printOptions.SimpleFilter)
            {
                if (!dataAsStr.Contains(filter))
                {
                    continue;
                }
                SetConsoleColors(ConsoleColor.Black, ConsoleColor.Yellow);
                Console.Write("f");
                return;
            }


            if (_printOptions.ProcessInfo != PrintOptions.ProcessDetails.None)
            {
                SetConsoleColors(ConsoleColor.Cyan);
                Console.Write('[');
                if (_printOptions.ProcessInfo == PrintOptions.ProcessDetails.Pid)
                {
                    Console.Write(data.ProcessID);
                }
                if (_printOptions.ProcessInfo == PrintOptions.ProcessDetails.ProcessName)
                {
                    Console.Write(data.ProcessName);
                }
                Console.Write("] ");
            }

            if (_printOptions.ExceptionInfo != 0)
            {
                SetConsoleColors(ConsoleColor.Red);
                var exceptionType = data.ExceptionType;
                if (_printOptions.ExceptionInfo == PrintOptions.ExceptionDetails.Full)
                {
                    Console.Write(exceptionType);
                }
                else
                {
                    var idx = exceptionType.LastIndexOf('.');
                    Console.Write(exceptionType.Substring(idx + 1));
                }
            }

            SetConsoleColors(ConsoleColor.Gray);
            Console.Write(" -> ");


            if (_printOptions.MessagePrint)
            {
                SetConsoleColors(ConsoleColor.Green);
                Console.Write(data.ExceptionMessage);
            }

            if (_printOptions.DataPrint)
            {
                Console.Write(dataAsStr);
            }

            Console.WriteLine();
        }