예제 #1
0
        public void WriteFailed(TimeSpan?time = null, Result res = null, bool lineAfter = false)
        {
            string elapsed = time.HasValue ? " - " + time.Value.TotalSeconds.ToString("F4") + "s" : "";

            using (ColorSetter.Set(ConsoleColor.Red))
            {
                Console.Write("FAILED" + elapsed);
                if (res != null)
                {
                    Console.WriteLine(res.Message);
                    Console.WriteLine(res.ExceptionMessage);
                }
            }
            if (res?.StackTrace != null)
            {
                using (ColorSetter.Set(ConsoleColor.DarkRed))
                {
                    foreach (var f in res.StackTrace)
                    {
                        Console.WriteLine(f);
                    }
                }
            }
            if (lineAfter)
            {
                Console.WriteLine();
            }
        }
예제 #2
0
 public void WriteWarning(string content)
 {
     using (ColorSetter.Set(ConsoleColor.Yellow))
     {
         Console.WriteLine(content);
     }
 }
예제 #3
0
 public void WriteColored(string text, ConsoleColor color)
 {
     using (ColorSetter.Set(color))
     {
         Console.Write(text);
     }
 }
예제 #4
0
        public Process GetCommandProcess(string folder, string command, string arguments, bool useShell = false)
        {
            ProcessStartInfo inf = new ProcessStartInfo
            {
                WorkingDirectory = folder,
                FileName         = command,
                UseShellExecute  = useShell
            };


            if (arguments != null)
            {
                inf.Arguments = arguments;
            }
            Console.WriteLine();
            using (ColorSetter.Set(ConsoleColor.Cyan))
            {
                Console.Write("Executing : ");
            }
            Console.WriteLine($"{command} {arguments}");

            var p = new Process();

            p.StartInfo = inf;
            return(p);
        }
예제 #5
0
        public void WriteSuccess(TimeSpan?time = null, int column = 0)
        {
            column = column == 0 ? SuccessCol : column;
            string elapsed = time.HasValue ? " " + time.Value.TotalSeconds.ToString("F4") + "s" : "";

            using (ColorSetter.Set(ConsoleColor.Green))
            {
                GotoColumn(column);
                Console.Write("SUCCESS" + elapsed);
            }
        }
예제 #6
0
 public void WriteException(string message, string type, string[] stack)
 {
     using (ColorSetter.Set(ConsoleColor.Red))
     {
         Console.WriteLine();
         Console.WriteLine("Exception Type :\t" + type);
         Console.WriteLine("Exception Message :\t" + message);
     }
     Console.WriteLine();
     if (stack != null)
     {
         using (ColorSetter.Set(ConsoleColor.DarkRed))
         {
             foreach (string st in stack)
             {
                 Console.WriteLine(st.Trim());
             }
         }
         Console.WriteLine();
     }
 }