Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.
1 change: 1 addition & 0 deletions dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ updates:
- package-ecosystem: "nuget"
ignore:
- dependency-name: "Autofac*"
- dependency-name: "Octopus*"
22 changes: 22 additions & 0 deletions source/Server.Extensibility/Diagnostics/CorrelationId.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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; }
}
}
87 changes: 87 additions & 0 deletions source/Server.Extensibility/HostServices/Diagnostics/ITaskLog.cs
Original file line number Diff line number Diff line change
@@ -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; }

/// <summary>
/// Opens a new child block for logging.
/// </summary>
/// <param name="messageText">Title of the new block.</param>
/// <returns>A child <see cref="ITaskLog" />.</returns>
ITaskLog CreateBlock(string messageText);

/// <summary>
/// Opens a new child block for logging.
/// </summary>
/// <param name="messageFormat">Format string for the message.</param>
/// <param name="args">Arguments for the format string.</param>
/// <returns>A child <see cref="ITaskLog" />.</returns>
[StringFormatMethod("messageFormat")]
ITaskLog CreateBlock(string messageFormat, params object[] args);

/// <summary>
/// Creates a child context with the same correlationId and additional sensitive values.
/// </summary>
/// <param name="sensitiveValues">Additional sensitive values.</param>
/// <returns>A new child task log</returns>
ITaskLog ChildContext(string[] sensitiveValues);

/// <summary>
/// Plans a new block of output that will be used in the future for grouping child blocks for logging.
/// </summary>
/// <param name="messageText">Title of the new block.</param>
/// <returns>A child <see cref="ITaskLog" />.</returns>
ITaskLog PlanGroupedBlock(string messageText);

/// <summary>
/// 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.
/// </summary>
/// <param name="messageText">Title of the new block.</param>
/// <returns>A child <see cref="ITaskLog" />.</returns>
ITaskLog PlanFutureBlock(string messageText);

/// <summary>
/// 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.
/// </summary>
/// <param name="messageFormat">Format string for the message.</param>
/// <param name="args">Arguments for the format string.</param>
/// <returns>A child <see cref="ITaskLog" />.</returns>
[StringFormatMethod("messageFormat")]
ITaskLog PlanFutureBlock(string messageFormat, params object[] args);

/// <summary>
/// Marks the current block as abandoned. Abandoned blocks won't be shown in the task log.
/// </summary>
void Abandon();

/// <summary>
/// If a block was previously abandoned using <see cref="Abandon" />, calling <see cref="Reinstate" /> will un-abandon
/// it.
/// </summary>
void Reinstate();

/// <summary>
/// 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.
/// </summary>
void Finish();

bool IsEnabled(LogCategory category);

void UpdateProgress(int progressPercentage, string messageText);

[StringFormatMethod("messageFormat")]
void UpdateProgressFormat(int progressPercentage, string messageFormat, params object[] args);
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
5 changes: 4 additions & 1 deletion source/Server.Extensibility/Server.Extensibility.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="4.9.4" />
<PackageReference Include="Octopus.Data" Version="5.3.0" />
<PackageReference Include="Octopus.Diagnostics" Version="2.0.0" />
<PackageReference Include="Octopus.TinyTypes" Version="0.1.411" />
<PackageReference Include="Octopus.TinyTypes" Version="0.1.418" />
<PackageReference Include="Octopus.TinyTypes" Version="0.1.425" />
<PackageReference Include="Octopus.Versioning" Version="5.0.1" />
<PackageReference Include="System.Security.Principal" Version="4.3.0" />
<PackageReference Include="Octopus.Data" Version="5.3.0" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.ComponentModel.Primitives" Version="4.3.0" />
</ItemGroup>
Expand Down