summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.Worker/Logging/ConsoleOutput.cs
blob: 8931d9712283e19f162a99f7da2dc58c208e083e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ConsoleOutput.cs" company="HandBrake Project (http://handbrake.fr)">
//   This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
// </copyright>
// <summary>
//   Defines the ConsoleOutput type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace HandBrake.Worker.Logging
{
    using System;

    public class ConsoleOutput
    {
        public static void WriteLine(string text, ConsoleColor colour = ConsoleColor.White, bool enableTimecode = false)
        {
            Console.ForegroundColor = colour;
            if (enableTimecode)
            {
                string time = DateTime.Now.ToString("HH:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo);
                Console.WriteLine("[{0}] {1}", time, text);
            }
            else
            {
                Console.WriteLine(text);
            }
          
            Console.ResetColor();
        }

        public static void ClearLine()
        {
            int currentLineCursor = Console.CursorTop;
            Console.SetCursorPosition(0, Console.CursorTop);
            Console.Write(new string(' ', Console.WindowWidth));
            Console.SetCursorPosition(0, currentLineCursor);
        }
    }
}