From 127b7daecc04e6fb282935723a5e31670b5ca652 Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 27 Mar 2024 08:41:18 +0100 Subject: [PATCH] Improves plugin log initialization --- Framework/Core/PluginTools.cs | 6 +++--- Framework/Logging/LogPrefixer.cs | 17 ++++++++++++----- .../CodexPlugin/CodexContainerRecipe.cs | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Framework/Core/PluginTools.cs b/Framework/Core/PluginTools.cs index ff77bae..5e1faee 100644 --- a/Framework/Core/PluginTools.cs +++ b/Framework/Core/PluginTools.cs @@ -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 onClientCreated) diff --git a/Framework/Logging/LogPrefixer.cs b/Framework/Logging/LogPrefixer.cs index a3d2f9f..69ab105 100644 --- a/Framework/Logging/LogPrefixer.cs +++ b/Framework/Logging/LogPrefixer.cs @@ -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) diff --git a/ProjectPlugins/CodexPlugin/CodexContainerRecipe.cs b/ProjectPlugins/CodexPlugin/CodexContainerRecipe.cs index ba356b2..7e7c111 100644 --- a/ProjectPlugins/CodexPlugin/CodexContainerRecipe.cs +++ b/ProjectPlugins/CodexPlugin/CodexContainerRecipe.cs @@ -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";