// Copyright Epic Games, Inc. All Rights Reserved. using System; using System.Collections.Generic; using EpicGames.Core; using Microsoft.Extensions.Logging; namespace EpicGames.Horde.Issues { /// /// Extension methods for logging issue data /// public static class IssueExtensions { /// /// Adds an issue fingerprint to a log event /// /// Log event to modify /// Fingerprint for the issue public static void AddIssueFingerprint(this LogEvent logEvent, IssueFingerprint fingerprint) => logEvent.AddProperty("@$issue", fingerprint); /// /// Enters a scope which annotates log messages with the supplied issue fingerprint /// /// Logger device to operate on /// Fingerprint for the issue /// Disposable object for the lifetime of this scope public static IDisposable? BeginIssueScope(this ILogger logger, IssueFingerprint fingerprint) { Dictionary properties = new Dictionary(1); properties.Add("@$issue", fingerprint); return logger.BeginScope(properties); } } }