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*" 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 diff --git a/source/Server.Extensibility/Domain/Deployments/DeploymentEvent.cs b/source/Server.Extensibility/Domain/Deployments/DeploymentEvent.cs index bbdce3b3..b989b3da 100644 --- a/source/Server.Extensibility/Domain/Deployments/DeploymentEvent.cs +++ b/source/Server.Extensibility/Domain/Deployments/DeploymentEvent.cs @@ -1,4 +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; @@ -16,13 +18,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/HostServices/Diagnostics/ITaskLog.cs b/source/Server.Extensibility/HostServices/Diagnostics/ITaskLog.cs new file mode 100644 index 00000000..9ec1b65c --- /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 + { + 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/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 diff --git a/source/Server.Extensibility/Server.Extensibility.csproj b/source/Server.Extensibility/Server.Extensibility.csproj index c72ecd83..0662a05b 100644 --- a/source/Server.Extensibility/Server.Extensibility.csproj +++ b/source/Server.Extensibility/Server.Extensibility.csproj @@ -27,10 +27,13 @@ + + + + -