2021-07-07 13:36:25 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
2022-05-22 15:55:26 +08:00
|
|
|
|
namespace RageCoop.Server
|
2021-07-07 13:36:25 +02:00
|
|
|
|
{
|
2021-08-20 17:28:13 +02:00
|
|
|
|
public class Logging
|
2021-07-07 13:36:25 +02:00
|
|
|
|
{
|
2022-04-10 14:34:55 +02:00
|
|
|
|
private static readonly object _lock = new();
|
2021-07-07 13:36:25 +02:00
|
|
|
|
|
|
|
|
|
public static void Info(string message)
|
|
|
|
|
{
|
2022-04-10 14:34:55 +02:00
|
|
|
|
lock (_lock)
|
2021-07-07 13:36:25 +02:00
|
|
|
|
{
|
|
|
|
|
string msg = string.Format("[{0}] [INFO] {1}", Date(), message);
|
|
|
|
|
|
|
|
|
|
Console.ForegroundColor = ConsoleColor.Gray;
|
|
|
|
|
Console.WriteLine(msg);
|
|
|
|
|
Console.ResetColor();
|
|
|
|
|
|
|
|
|
|
using StreamWriter sw = new("log.txt", true);
|
|
|
|
|
sw.WriteLine(msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Warning(string message)
|
|
|
|
|
{
|
2022-04-10 14:34:55 +02:00
|
|
|
|
lock (_lock)
|
2021-07-07 13:36:25 +02:00
|
|
|
|
{
|
|
|
|
|
string msg = string.Format("[{0}] [WARNING] {1}", Date(), message);
|
|
|
|
|
|
|
|
|
|
Console.ForegroundColor = ConsoleColor.Yellow;
|
|
|
|
|
Console.WriteLine(msg);
|
|
|
|
|
Console.ResetColor();
|
|
|
|
|
|
|
|
|
|
using StreamWriter sw = new("log.txt", true);
|
|
|
|
|
sw.WriteLine(msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Error(string message)
|
|
|
|
|
{
|
2022-04-10 14:34:55 +02:00
|
|
|
|
lock (_lock)
|
2021-07-07 13:36:25 +02:00
|
|
|
|
{
|
|
|
|
|
string msg = string.Format("[{0}] [ERROR] {1}", Date(), message);
|
|
|
|
|
|
|
|
|
|
Console.ForegroundColor = ConsoleColor.Red;
|
|
|
|
|
Console.WriteLine(msg);
|
|
|
|
|
Console.ResetColor();
|
|
|
|
|
|
|
|
|
|
using StreamWriter sw = new("log.txt", true);
|
|
|
|
|
sw.WriteLine(msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Debug(string message)
|
|
|
|
|
{
|
|
|
|
|
if (!Server.MainSettings.DebugMode)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-10 14:34:55 +02:00
|
|
|
|
lock (_lock)
|
2021-07-07 13:36:25 +02:00
|
|
|
|
{
|
|
|
|
|
string msg = string.Format("[{0}] [DEBUG] {1}", Date(), message);
|
|
|
|
|
|
|
|
|
|
Console.ForegroundColor = ConsoleColor.Blue;
|
|
|
|
|
Console.WriteLine(msg);
|
|
|
|
|
Console.ResetColor();
|
|
|
|
|
|
|
|
|
|
using StreamWriter sw = new("log.txt", true);
|
|
|
|
|
sw.WriteLine(msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private static string Date()
|
|
|
|
|
{
|
|
|
|
|
return DateTime.Now.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|