ResourceManager!
This commit is contained in:
47
DaggerFramework/Source/Utils/Logger.cs
Normal file
47
DaggerFramework/Source/Utils/Logger.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
namespace DaggerFramework.Utils
|
||||
{
|
||||
public class Logger
|
||||
{
|
||||
public static Action<string, LogType>? OnLog;
|
||||
public Logger(string className)
|
||||
{
|
||||
_className = className;
|
||||
}
|
||||
public void Info(object what)
|
||||
{
|
||||
LogType logType = LogType.Info;
|
||||
string message = $"({DateFormat}) [{logType.ToString().ToUpper()}/{_className}] {what}";
|
||||
LogConsole(message);
|
||||
OnLog?.Invoke(message, logType);
|
||||
}
|
||||
|
||||
public void Warn(object what)
|
||||
{
|
||||
LogType logType = LogType.Warn;
|
||||
string message = $"({DateFormat}) [{logType.ToString().ToUpper()}/{_className}] {what}";
|
||||
LogConsole(message);
|
||||
OnLog?.Invoke(message, logType);
|
||||
}
|
||||
|
||||
public void Error(object what)
|
||||
{
|
||||
LogType logType = LogType.Error;
|
||||
string message = $"({DateFormat}) [{logType.ToString().ToUpper()}/{_className}] {what}";
|
||||
LogConsole(message);
|
||||
OnLog?.Invoke(message, logType);
|
||||
}
|
||||
|
||||
|
||||
private static string DateFormat => $"{DateTime.Now:t}";
|
||||
|
||||
private static void LogConsole(string what) => Console.WriteLine(what);
|
||||
private readonly string _className;
|
||||
}
|
||||
|
||||
public enum LogType
|
||||
{
|
||||
Info,
|
||||
Warn,
|
||||
Error
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user