Exemplo n.º 1
0
 private static void Log24Bit(XTermColor color,
                              string category,
                              string message,
                              params object[] arg)
 {
     Log24Bit(color, true, Console.Out, category, message, arg);
 }
Exemplo n.º 2
0
 private static void Log24Bit(XTermColor color, string category, string message, params object[] arg)
 {
     if (!Enabled)
     {
         return;
     }
     if (!EnableVT())
     {
         Log4Bit(ConsoleColor.Gray, true, category, message, arg);
         return;
     }
     Log24Bit(color.ToForeground(), null, true, category, message, arg);
 }
Exemplo n.º 3
0
        public static void Log(XTermColor color, bool newline, TextWriter writer, string?category, string?level, string message)
        {
            if (!Enabled)
            {
                return;
            }

            if (!EnableVT())
            {
                Log4Bit(ConsoleColor.Gray, newline, writer, category, level, message);
                return;
            }

            Log(color.ToForeground(), default, newline, writer, category, level, message);
Exemplo n.º 4
0
        public static void Log24Bit(XTermColor color, bool newline, TextWriter writer, string category, string message, params object[] arg)
        {
            if (!Enabled)
            {
                return;
            }
            if (!EnableVT())
            {
                Log4Bit(ConsoleColor.Gray, newline, writer, category, message, arg);
                return;
            }

            Log24Bit(color.ToForeground(), null, newline, writer, category, message, arg);
        }
Exemplo n.º 5
0
 public static string ToBackground(this XTermColor color)
 {
     return($"\x1b[48;5;{(byte) color}m");
 }
Exemplo n.º 6
0
 public static string ToForeground(this XTermColor color)
 {
     return($"\x1b[38;5;{(byte) color}m");
 }
Exemplo n.º 7
0
        public static void LogProgress(string message, string pre, string post, double value, XTermColor messageColor, XTermColor preColor, XTermColor postColor, XTermColor brickColor, XTermColor processColor, bool showProgressValue, XTermColor processValueColor)
        {
            if (Console.IsOutputRedirected)
            {
                return;
            }
            var width = Console.WindowWidth;
            var empty = new char[width];

            Fill(empty, ' ');
            if (message != LastMessage)
            {
                Console.Out.Write(empty);
                Console.CursorLeft = 0;
                LastMessage        = message;
                Logger.Log24Bit(messageColor, true, Console.Out, null, message);
            }
            Console.Out.Write(empty);
            Console.CursorLeft = 0;
            var remaining = width - pre.Length - post.Length - 4;

            Logger.Log24Bit(preColor, false, Console.Out, null, pre);
            if (remaining > 0)
            {
                Logger.Log24Bit(brickColor, false, Console.Out, null, " [");
                empty = new char[remaining];
                Fill(empty, ' ');
                Fill(empty, '=', 0, (int)System.Math.Round(remaining * System.Math.Min(value, 1)));
                Logger.Log24Bit(processColor, false, Console.Out, null, string.Join("", empty));
                Logger.Log24Bit(brickColor, false, Console.Out, null, "] ");

                if (showProgressValue && remaining > 6)
                {
                    var valueText = (System.Math.Min(value, 1) * 100).ToString().Split('.')[0] + "%";
                    Console.CursorLeft = pre.Length + 2 + (int)System.Math.Floor(remaining / 2.0d - valueText.Length / 2.0d);
                    Logger.Log24Bit(processValueColor, false, Console.Out, null, valueText);
                    Console.CursorLeft = width - post.Length;
                }
            }
            Logger.Log24Bit(postColor, false, Console.Out, null, post);
            Console.CursorLeft = Console.WindowWidth - 1;
            Console.CursorTop -= 1;
        }