Initial commit
This commit is contained in:
51
Creator/Helper/Log.cs
Normal file
51
Creator/Helper/Log.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using System;
|
||||
|
||||
namespace KattekerCreator.Helper
|
||||
{
|
||||
public static class Log
|
||||
{
|
||||
private const string Info = "INFO";
|
||||
private const string Error = "ERROR";
|
||||
|
||||
public static void WriteInfoLine(string text)
|
||||
{
|
||||
using (var c = new ConsoleWithOtherColor())
|
||||
{
|
||||
c.WriteLine($"{Info} [{DateTime.Now:G}] {text}");
|
||||
}
|
||||
}
|
||||
|
||||
public static void WriteErrorLine(string text)
|
||||
{
|
||||
using (var c = new ConsoleWithOtherColor(ConsoleColor.DarkRed))
|
||||
{
|
||||
c.WriteLine($"{Error} [{DateTime.Now:G}] {text}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ConsoleWithOtherColor : IDisposable
|
||||
{
|
||||
public ConsoleWithOtherColor()
|
||||
{
|
||||
}
|
||||
|
||||
private readonly ConsoleColor? _defaultColor;
|
||||
|
||||
public ConsoleWithOtherColor(ConsoleColor color)
|
||||
{
|
||||
_defaultColor = Console.ForegroundColor;
|
||||
Console.ForegroundColor = color;
|
||||
}
|
||||
|
||||
public void WriteLine(string text)
|
||||
{
|
||||
Console.WriteLine(text);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_defaultColor != null) Console.ForegroundColor = _defaultColor.Value;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user