2024-06-19 08:39:14 +00:00
|
|
|
|
using Logging;
|
|
|
|
|
|
|
|
|
|
namespace KubernetesWorkflow
|
2023-11-12 09:07:23 +00:00
|
|
|
|
{
|
|
|
|
|
public interface ILogHandler
|
|
|
|
|
{
|
|
|
|
|
void Log(Stream log);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public abstract class LogHandler : ILogHandler
|
|
|
|
|
{
|
|
|
|
|
public void Log(Stream log)
|
|
|
|
|
{
|
|
|
|
|
using var reader = new StreamReader(log);
|
|
|
|
|
var line = reader.ReadLine();
|
|
|
|
|
while (line != null)
|
|
|
|
|
{
|
|
|
|
|
ProcessLine(line);
|
|
|
|
|
line = reader.ReadLine();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected abstract void ProcessLine(string line);
|
|
|
|
|
}
|
2024-06-19 08:39:14 +00:00
|
|
|
|
|
|
|
|
|
public class WriteToFileLogHandler : LogHandler, ILogHandler
|
|
|
|
|
{
|
|
|
|
|
public WriteToFileLogHandler(ILog sourceLog, string description)
|
|
|
|
|
{
|
|
|
|
|
LogFile = sourceLog.CreateSubfile();
|
|
|
|
|
|
|
|
|
|
var msg = $"{description} -->> {LogFile.FullFilename}";
|
|
|
|
|
sourceLog.Log(msg);
|
|
|
|
|
|
|
|
|
|
LogFile.Write(msg);
|
|
|
|
|
LogFile.WriteRaw(description);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public LogFile LogFile { get; }
|
|
|
|
|
|
|
|
|
|
protected override void ProcessLine(string line)
|
|
|
|
|
{
|
|
|
|
|
LogFile.WriteRaw(line);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-11-12 09:07:23 +00:00
|
|
|
|
}
|