34 lines
968 B
C#
34 lines
968 B
C#
namespace MxGateway.Server.Diagnostics;
|
|
|
|
public sealed record GatewayLogScope(
|
|
string? SessionId = null,
|
|
int? WorkerProcessId = null,
|
|
ulong? CorrelationId = null,
|
|
string? CommandMethod = null,
|
|
string? ClientIdentity = null)
|
|
{
|
|
public IReadOnlyDictionary<string, object?> ToDictionary()
|
|
{
|
|
Dictionary<string, object?> values = [];
|
|
|
|
AddIfPresent(values, "SessionId", SessionId);
|
|
AddIfPresent(values, "WorkerProcessId", WorkerProcessId);
|
|
AddIfPresent(values, "CorrelationId", CorrelationId);
|
|
AddIfPresent(values, "CommandMethod", CommandMethod);
|
|
AddIfPresent(values, "ClientIdentity", GatewayLogRedactor.RedactClientIdentity(ClientIdentity));
|
|
|
|
return values;
|
|
}
|
|
|
|
private static void AddIfPresent(
|
|
Dictionary<string, object?> values,
|
|
string key,
|
|
object? value)
|
|
{
|
|
if (value is not null)
|
|
{
|
|
values[key] = value;
|
|
}
|
|
}
|
|
}
|