Improves plugin log initialization

This commit is contained in:
Ben 2024-03-27 08:41:18 +01:00
parent 9e9773f45d
commit 127b7daecc
No known key found for this signature in database
GPG Key ID: 541B9D8C9F1426A1
3 changed files with 16 additions and 9 deletions

View File

@ -36,11 +36,11 @@ namespace Core
private readonly ITimeSet timeSet;
private readonly WorkflowCreator workflowCreator;
private readonly IFileManager fileManager;
private ILog log;
private readonly LogPrefixer log;
internal PluginTools(ILog log, WorkflowCreator workflowCreator, string fileManagerRootFolder, ITimeSet timeSet)
{
this.log = log;
this.log = new LogPrefixer(log);
this.workflowCreator = workflowCreator;
this.timeSet = timeSet;
fileManager = new FileManager(log, fileManagerRootFolder);
@ -48,7 +48,7 @@ namespace Core
public void ApplyLogPrefix(string prefix)
{
log = new LogPrefixer(log, prefix);
log.Prefix = prefix;
}
public IHttp CreateHttp(Action<HttpClient> onClientCreated)

View File

@ -3,14 +3,21 @@
public class LogPrefixer : ILog
{
private readonly ILog backingLog;
private readonly string prefix;
public LogPrefixer(ILog backingLog)
{
this.backingLog = backingLog;
}
public LogPrefixer(ILog backingLog, string prefix)
{
this.backingLog = backingLog;
this.prefix = prefix;
Prefix = prefix;
}
public string Prefix { get; set; } = string.Empty;
public LogFile CreateSubfile(string ext = "log")
{
return backingLog.CreateSubfile(ext);
@ -18,17 +25,17 @@
public void Debug(string message = "", int skipFrames = 0)
{
backingLog.Debug(prefix + message, skipFrames);
backingLog.Debug(Prefix + message, skipFrames);
}
public void Error(string message)
{
backingLog.Error(prefix + message);
backingLog.Error(Prefix + message);
}
public void Log(string message)
{
backingLog.Log(prefix + message);
backingLog.Log(Prefix + message);
}
public void AddStringReplace(string from, string to)

View File

@ -7,7 +7,7 @@ namespace CodexPlugin
{
public class CodexContainerRecipe : ContainerRecipeFactory
{
private const string DefaultDockerImage = "codexstorage/nim-codex:sha-455b95d-dist-tests";
private const string DefaultDockerImage = "codexstorage/nim-codex:sha-cd280d4-dist-tests";
public const string ApiPortTag = "codex_api_port";
public const string ListenPortTag = "codex_listen_port";
public const string MetricsPortTag = "codex_metrics_port";