Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions src/Dapr.Workflow/WorkflowLoggingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,20 @@

namespace Dapr.Workflow
{
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Configuration;
using System.Collections.Concurrent;

/// <summary>
/// Defines runtime options for workflows.
/// </summary>
internal sealed class WorkflowLoggingService : IHostedService
{
private readonly ILogger<WorkflowLoggingService> logger;
private static readonly HashSet<string> registeredWorkflows = new();
private static readonly HashSet<string> registeredActivities = new();
private static readonly ConcurrentDictionary<string, byte> registeredWorkflows = new();
private static readonly ConcurrentDictionary<string, byte> registeredActivities = new();

public WorkflowLoggingService(ILogger<WorkflowLoggingService> logger)
{
Expand All @@ -38,13 +37,13 @@ public Task StartAsync(CancellationToken cancellationToken)
this.logger.Log(LogLevel.Information, "WorkflowLoggingService started");

this.logger.Log(LogLevel.Information, "List of registered workflows");
foreach (string item in registeredWorkflows)
foreach (string item in registeredWorkflows.Keys)
{
this.logger.Log(LogLevel.Information, item);
}

this.logger.Log(LogLevel.Information, "List of registered activities:");
foreach (string item in registeredActivities)
foreach (string item in registeredActivities.Keys)
{
this.logger.Log(LogLevel.Information, item);
}
Expand All @@ -55,18 +54,18 @@ public Task StartAsync(CancellationToken cancellationToken)
public Task StopAsync(CancellationToken cancellationToken)
{
this.logger.Log(LogLevel.Information, "WorkflowLoggingService stopped");

return Task.CompletedTask;
}

public static void LogWorkflowName(string workflowName)
{
registeredWorkflows.Add(workflowName);
registeredWorkflows.TryAdd(workflowName, 0);
}

public static void LogActivityName(string activityName)
{
registeredActivities.Add(activityName);
registeredActivities.TryAdd(activityName, 0);
}

}
Expand Down
Loading