cs-codex-dist-tests/Framework/Logging/LogPrefixer.cs

47 lines
1.0 KiB
C#
Raw Normal View History

2023-09-13 07:12:18 +00:00
namespace Logging
{
public class LogPrefixer : ILog
{
private readonly ILog backingLog;
2024-03-27 07:41:18 +00:00
public LogPrefixer(ILog backingLog)
{
this.backingLog = backingLog;
}
2023-09-13 07:12:18 +00:00
public LogPrefixer(ILog backingLog, string prefix)
{
this.backingLog = backingLog;
2024-03-27 07:41:18 +00:00
Prefix = prefix;
2023-09-13 07:12:18 +00:00
}
2024-03-27 07:41:18 +00:00
public string Prefix { get; set; } = string.Empty;
2023-09-13 07:12:18 +00:00
public LogFile CreateSubfile(string ext = "log")
{
return backingLog.CreateSubfile(ext);
}
public void Debug(string message = "", int skipFrames = 0)
{
2024-03-27 07:41:18 +00:00
backingLog.Debug(Prefix + message, skipFrames);
2023-09-13 07:12:18 +00:00
}
public void Error(string message)
{
2024-03-27 07:41:18 +00:00
backingLog.Error(Prefix + message);
2023-09-13 07:12:18 +00:00
}
public void Log(string message)
{
2024-03-27 07:41:18 +00:00
backingLog.Log(Prefix + message);
2023-09-13 07:12:18 +00:00
}
2023-09-20 11:33:58 +00:00
public void AddStringReplace(string from, string to)
{
backingLog.AddStringReplace(from, to);
}
2023-09-13 07:12:18 +00:00
}
}