2023-05-20 21:47:54 +02:00
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace Logging;
|
|
|
|
|
|
|
|
|
|
public abstract class LoggerBase : TextWriter
|
|
|
|
|
{
|
|
|
|
|
public override Encoding Encoding { get; }
|
|
|
|
|
|
2023-07-16 17:33:15 +02:00
|
|
|
|
public LoggerBase(Encoding? encoding = null)
|
2023-05-20 21:47:54 +02:00
|
|
|
|
{
|
|
|
|
|
this.Encoding = encoding ?? Encoding.ASCII;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-20 22:10:24 +02:00
|
|
|
|
public void Write(string caller, string? value)
|
2023-05-20 21:47:54 +02:00
|
|
|
|
{
|
|
|
|
|
if (value is null)
|
|
|
|
|
return;
|
|
|
|
|
|
2023-07-16 17:33:15 +02:00
|
|
|
|
LogMessage message = new (DateTime.Now, caller, value);
|
2023-05-20 21:47:54 +02:00
|
|
|
|
|
|
|
|
|
Write(message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected abstract void Write(LogMessage message);
|
|
|
|
|
}
|