From 19bf47261817b3add33d26e11cde9ac5c39e600a Mon Sep 17 00:00:00 2001 From: slewis74 Date: Mon, 11 Jan 2021 07:51:41 +1000 Subject: [PATCH 1/7] Deployment events now carry the task log reference --- .../Domain/Deployments/DeploymentEvent.cs | 5 ++++- source/Server.Extensibility/Server.Extensibility.csproj | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/source/Server.Extensibility/Domain/Deployments/DeploymentEvent.cs b/source/Server.Extensibility/Domain/Deployments/DeploymentEvent.cs index bbdce3b3..03c737cd 100644 --- a/source/Server.Extensibility/Domain/Deployments/DeploymentEvent.cs +++ b/source/Server.Extensibility/Domain/Deployments/DeploymentEvent.cs @@ -1,4 +1,5 @@ using System; +using Octopus.Diagnostics; using Octopus.Server.Extensibility.HostServices.Domain.Events; using Octopus.Server.Extensibility.HostServices.Model.Projects; @@ -16,13 +17,15 @@ public enum DeploymentEventType public class DeploymentEvent : DomainEvent { - public DeploymentEvent(DeploymentEventType eventType, IDeployment deployment) + public DeploymentEvent(DeploymentEventType eventType, IDeployment deployment, ITaskLog taskLog) { EventType = eventType; Deployment = deployment; + TaskLog = taskLog; } public DeploymentEventType EventType { get; } public IDeployment Deployment { get; } + public ITaskLog TaskLog { get; } } } \ No newline at end of file diff --git a/source/Server.Extensibility/Server.Extensibility.csproj b/source/Server.Extensibility/Server.Extensibility.csproj index c24c5e6e..2f31522c 100644 --- a/source/Server.Extensibility/Server.Extensibility.csproj +++ b/source/Server.Extensibility/Server.Extensibility.csproj @@ -27,6 +27,7 @@ + From 496966b7da2809917bd5b8314a733b139f8529b4 Mon Sep 17 00:00:00 2001 From: slewis74 Date: Thu, 25 Feb 2021 09:34:17 +1000 Subject: [PATCH 2/7] moved ITaskLog out of diagnostics and into here --- .../Domain/Deployments/DeploymentEvent.cs | 1 + .../HostServices/Diagnostics/ITaskLog.cs | 87 +++++++++++++++++++ .../Server.Extensibility.csproj | 2 +- 3 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 source/Server.Extensibility/HostServices/Diagnostics/ITaskLog.cs diff --git a/source/Server.Extensibility/Domain/Deployments/DeploymentEvent.cs b/source/Server.Extensibility/Domain/Deployments/DeploymentEvent.cs index 03c737cd..b989b3da 100644 --- a/source/Server.Extensibility/Domain/Deployments/DeploymentEvent.cs +++ b/source/Server.Extensibility/Domain/Deployments/DeploymentEvent.cs @@ -1,5 +1,6 @@ using System; using Octopus.Diagnostics; +using Octopus.Server.Extensibility.HostServices.Diagnostics; using Octopus.Server.Extensibility.HostServices.Domain.Events; using Octopus.Server.Extensibility.HostServices.Model.Projects; diff --git a/source/Server.Extensibility/HostServices/Diagnostics/ITaskLog.cs b/source/Server.Extensibility/HostServices/Diagnostics/ITaskLog.cs new file mode 100644 index 00000000..21e87097 --- /dev/null +++ b/source/Server.Extensibility/HostServices/Diagnostics/ITaskLog.cs @@ -0,0 +1,87 @@ +using System; +using Octopus.Diagnostics; + +namespace Octopus.Server.Extensibility.HostServices.Diagnostics +{ + public interface ITaskLog : ILog, IDisposable + { + bool IsVerboseEnabled { get; } + bool IsErrorEnabled { get; } + bool IsFatalEnabled { get; } + bool IsInfoEnabled { get; } + bool IsTraceEnabled { get; } + bool IsWarnEnabled { get; } + + /// + /// Opens a new child block for logging. + /// + /// Title of the new block. + /// A child . + ITaskLog CreateBlock(string messageText); + + /// + /// Opens a new child block for logging. + /// + /// Format string for the message. + /// Arguments for the format string. + /// A child . + [StringFormatMethod("messageFormat")] + ITaskLog CreateBlock(string messageFormat, params object[] args); + + /// + /// Creates a child context with the same correlationId and additional sensitive values. + /// + /// Additional sensitive values. + /// A new child task log + ITaskLog ChildContext(string[] sensitiveValues); + + /// + /// Plans a new block of output that will be used in the future for grouping child blocks for logging. + /// + /// Title of the new block. + /// A child . + ITaskLog PlanGroupedBlock(string messageText); + + /// + /// Plans a new block of log output that will be used in the future. This is typically used for high-level log + /// information, such as the steps in a big deployment process. + /// + /// Title of the new block. + /// A child . + ITaskLog PlanFutureBlock(string messageText); + + /// + /// Plans a new block of log output that will be used in the future. This is typically used for high-level log + /// information, such as the steps in a big deployment process. + /// + /// Format string for the message. + /// Arguments for the format string. + /// A child . + [StringFormatMethod("messageFormat")] + ITaskLog PlanFutureBlock(string messageFormat, params object[] args); + + /// + /// Marks the current block as abandoned. Abandoned blocks won't be shown in the task log. + /// + void Abandon(); + + /// + /// If a block was previously abandoned using , calling will un-abandon + /// it. + /// + void Reinstate(); + + /// + /// Marks the current block as finished. If there were any errors, it will be finished with errors. If there were no + /// errors, it will be assumed to be successful. + /// + void Finish(); + + bool IsEnabled(LogCategory category); + + void UpdateProgress(int progressPercentage, string messageText); + + [StringFormatMethod("messageFormat")] + void UpdateProgressFormat(int progressPercentage, string messageFormat, params object[] args); + } +} \ No newline at end of file diff --git a/source/Server.Extensibility/Server.Extensibility.csproj b/source/Server.Extensibility/Server.Extensibility.csproj index 2f31522c..f32cb067 100644 --- a/source/Server.Extensibility/Server.Extensibility.csproj +++ b/source/Server.Extensibility/Server.Extensibility.csproj @@ -27,7 +27,7 @@ - + From 17349d0546a9c00dd4a6c3304f5447ba10db28b4 Mon Sep 17 00:00:00 2001 From: slewis74 Date: Wed, 3 Mar 2021 08:17:42 +1000 Subject: [PATCH 3/7] latest Diagnostic package and dropping the idea of task log being disposable --- .../Server.Extensibility/HostServices/Diagnostics/ITaskLog.cs | 2 +- source/Server.Extensibility/Server.Extensibility.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/Server.Extensibility/HostServices/Diagnostics/ITaskLog.cs b/source/Server.Extensibility/HostServices/Diagnostics/ITaskLog.cs index 21e87097..9ec1b65c 100644 --- a/source/Server.Extensibility/HostServices/Diagnostics/ITaskLog.cs +++ b/source/Server.Extensibility/HostServices/Diagnostics/ITaskLog.cs @@ -3,7 +3,7 @@ namespace Octopus.Server.Extensibility.HostServices.Diagnostics { - public interface ITaskLog : ILog, IDisposable + public interface ITaskLog : ILog { bool IsVerboseEnabled { get; } bool IsErrorEnabled { get; } diff --git a/source/Server.Extensibility/Server.Extensibility.csproj b/source/Server.Extensibility/Server.Extensibility.csproj index e059c186..b838e089 100644 --- a/source/Server.Extensibility/Server.Extensibility.csproj +++ b/source/Server.Extensibility/Server.Extensibility.csproj @@ -27,7 +27,7 @@ - + From a35ec01af0baaa6ed6625c1ce7bf8600a81c05a2 Mon Sep 17 00:00:00 2001 From: slewis74 Date: Thu, 4 Mar 2021 08:49:54 +1000 Subject: [PATCH 4/7] package references updates after more dependabot induced merge pain --- source/Server.Extensibility/Server.Extensibility.csproj | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/source/Server.Extensibility/Server.Extensibility.csproj b/source/Server.Extensibility/Server.Extensibility.csproj index b838e089..6dc44af9 100644 --- a/source/Server.Extensibility/Server.Extensibility.csproj +++ b/source/Server.Extensibility/Server.Extensibility.csproj @@ -26,15 +26,12 @@ - - - - + + - From 405213a2f4a1e4cdc7120c6eabcd1d4f641313f1 Mon Sep 17 00:00:00 2001 From: slewis74 Date: Thu, 4 Mar 2021 08:51:12 +1000 Subject: [PATCH 5/7] stop the pain --- dependabot.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/dependabot.yml b/dependabot.yml index 57d5df61..6e251bc7 100644 --- a/dependabot.yml +++ b/dependabot.yml @@ -3,3 +3,4 @@ updates: - package-ecosystem: "nuget" ignore: - dependency-name: "Autofac*" + - dependency-name: "Octopus*" From 3d57e21558e0fdf0f36b4c94d09da47e25ae25ac Mon Sep 17 00:00:00 2001 From: slewis74 Date: Sat, 6 Mar 2021 14:51:57 +1000 Subject: [PATCH 6/7] CanonicalTagNameMapper logs when it can't map --- .../HostServices/Mapping/ICanonicalTagNameMapper.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/Server.Extensibility/HostServices/Mapping/ICanonicalTagNameMapper.cs b/source/Server.Extensibility/HostServices/Mapping/ICanonicalTagNameMapper.cs index 82f64884..fb590064 100644 --- a/source/Server.Extensibility/HostServices/Mapping/ICanonicalTagNameMapper.cs +++ b/source/Server.Extensibility/HostServices/Mapping/ICanonicalTagNameMapper.cs @@ -1,10 +1,11 @@ using System; +using Octopus.Diagnostics; namespace Octopus.Server.Extensibility.HostServices.Mapping { public interface ICanonicalTagNameMapper { string GetTagIdFromCanonicalTagName(string canonicalTagName); - string GetCanonicalTagNameFromTagId(string tagId); + string? GetCanonicalTagNameFromTagId(string canonicalTagId, ILog log); } } \ No newline at end of file From 80eac34bcc12621c4fa7abb3841e9e55ccffcb58 Mon Sep 17 00:00:00 2001 From: slewis74 Date: Mon, 8 Mar 2021 13:17:46 +1000 Subject: [PATCH 7/7] moving CorrelationId into here --- .../Diagnostics/CorrelationId.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 source/Server.Extensibility/Diagnostics/CorrelationId.cs diff --git a/source/Server.Extensibility/Diagnostics/CorrelationId.cs b/source/Server.Extensibility/Diagnostics/CorrelationId.cs new file mode 100644 index 00000000..26ba5d14 --- /dev/null +++ b/source/Server.Extensibility/Diagnostics/CorrelationId.cs @@ -0,0 +1,22 @@ +using System; + +namespace Octopus.Server.Extensibility.Diagnostics +{ + public class CorrelationId + { + public CorrelationId() + { + Id = Guid.NewGuid().ToString("N"); + } + + public CorrelationId(string id) + { + Id = id; + } + + public string Id { get; } + + public override string ToString() + => Id; + } +} \ No newline at end of file