2022-10-02 18:31:08 +08:00
|
|
|
|
namespace MinecraftClient.Logger
|
2021-03-07 14:23:26 +08:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Abstract class providing basic implementation of the ILogger interface
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public abstract class LoggerBase : ILogger
|
|
|
|
|
|
{
|
|
|
|
|
|
private bool debugEnabled = false;
|
|
|
|
|
|
private bool warnEnabled = true;
|
|
|
|
|
|
private bool infoEnabled = true;
|
|
|
|
|
|
private bool errorEnabled = true;
|
|
|
|
|
|
private bool chatEnabled = true;
|
|
|
|
|
|
public bool DebugEnabled { get { return debugEnabled; } set { debugEnabled = value; } }
|
|
|
|
|
|
public bool WarnEnabled { get { return warnEnabled; } set { warnEnabled = value; } }
|
|
|
|
|
|
public bool InfoEnabled { get { return infoEnabled; } set { infoEnabled = value; } }
|
|
|
|
|
|
public bool ErrorEnabled { get { return errorEnabled; } set { errorEnabled = value; } }
|
|
|
|
|
|
public bool ChatEnabled { get { return chatEnabled; } set { chatEnabled = value; } }
|
|
|
|
|
|
|
|
|
|
|
|
public abstract void Chat(string msg);
|
|
|
|
|
|
|
|
|
|
|
|
public void Chat(string msg, params object[] args)
|
|
|
|
|
|
{
|
|
|
|
|
|
Chat(string.Format(msg, args));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Chat(object msg)
|
|
|
|
|
|
{
|
2022-10-02 18:31:08 +08:00
|
|
|
|
Chat(msg.ToString() ?? string.Empty);
|
2021-03-07 14:23:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public abstract void Debug(string msg);
|
|
|
|
|
|
|
|
|
|
|
|
public void Debug(string msg, params object[] args)
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug(string.Format(msg, args));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Debug(object msg)
|
|
|
|
|
|
{
|
2022-10-02 18:31:08 +08:00
|
|
|
|
Debug(msg.ToString() ?? string.Empty);
|
2021-03-07 14:23:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public abstract void Error(string msg);
|
|
|
|
|
|
|
|
|
|
|
|
public void Error(string msg, params object[] args)
|
|
|
|
|
|
{
|
|
|
|
|
|
Error(string.Format(msg, args));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Error(object msg)
|
|
|
|
|
|
{
|
2022-10-02 18:31:08 +08:00
|
|
|
|
Error(msg.ToString() ?? string.Empty);
|
2021-03-07 14:23:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public abstract void Info(string msg);
|
|
|
|
|
|
|
|
|
|
|
|
public void Info(string msg, params object[] args)
|
|
|
|
|
|
{
|
|
|
|
|
|
Info(string.Format(msg, args));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Info(object msg)
|
|
|
|
|
|
{
|
2022-10-02 18:31:08 +08:00
|
|
|
|
Info(msg.ToString() ?? string.Empty);
|
2021-03-07 14:23:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public abstract void Warn(string msg);
|
|
|
|
|
|
|
|
|
|
|
|
public void Warn(string msg, params object[] args)
|
|
|
|
|
|
{
|
|
|
|
|
|
Warn(string.Format(msg, args));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Warn(object msg)
|
|
|
|
|
|
{
|
2022-10-02 18:31:08 +08:00
|
|
|
|
Warn(msg.ToString() ?? string.Empty);
|
2021-03-07 14:23:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual void Log(object msg)
|
|
|
|
|
|
{
|
2022-10-02 18:31:08 +08:00
|
|
|
|
ConsoleIO.WriteLineFormatted(msg.ToString() ?? string.Empty);
|
2021-03-07 14:23:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual void Log(string msg)
|
|
|
|
|
|
{
|
|
|
|
|
|
ConsoleIO.WriteLineFormatted(msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual void Log(string msg, params object[] args)
|
|
|
|
|
|
{
|
|
|
|
|
|
ConsoleIO.WriteLineFormatted(string.Format(msg, args));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|