61 lines
1.4 KiB
C#
Raw Normal View History

2023-09-13 09:12:18 +02:00
namespace Logging
{
public class LogPrefixer : ILog
{
private readonly ILog backingLog;
2024-03-27 08:41:18 +01:00
public LogPrefixer(ILog backingLog)
{
this.backingLog = backingLog;
}
2023-09-13 09:12:18 +02:00
public LogPrefixer(ILog backingLog, string prefix)
{
this.backingLog = backingLog;
2024-03-27 08:41:18 +01:00
Prefix = prefix;
2023-09-13 09:12:18 +02:00
}
2024-03-27 08:41:18 +01:00
public string Prefix { get; set; } = string.Empty;
public LogFile CreateSubfile(string addName, string ext = "log")
2023-09-13 09:12:18 +02:00
{
return backingLog.CreateSubfile(addName, ext);
2023-09-13 09:12:18 +02:00
}
public void Debug(string message = "", int skipFrames = 0)
{
2025-05-20 14:16:33 +02:00
backingLog.Debug(GetPrefix() + message, skipFrames);
2023-09-13 09:12:18 +02:00
}
public void Error(string message)
{
2025-05-20 14:16:33 +02:00
backingLog.Error(GetPrefix() + message);
2023-09-13 09:12:18 +02:00
}
public void Log(string message)
{
2025-05-20 14:16:33 +02:00
backingLog.Log(GetPrefix() + message);
2023-09-13 09:12:18 +02:00
}
2023-09-20 13:33:58 +02:00
public void AddStringReplace(string from, string to)
{
backingLog.AddStringReplace(from, to);
}
public void Raw(string message)
{
backingLog.Raw(message);
}
public string GetFullName()
{
return backingLog.GetFullName();
}
2025-05-20 14:16:33 +02:00
protected virtual string GetPrefix()
{
return Prefix;
}
2023-09-13 09:12:18 +02:00
}
}