// // Licensed under the MIT License. See LICENSE file in the project root for full license information. // namespace MUnique.OpenMU.GameLogic; /// /// Extensions for s. /// public static class LoggerExtensions { /// /// Begins a logical operation scope. /// /// The logger. /// The key value pairs which describe the scope. /// An that ends the logical operation scope on dispose. public static IDisposable? BeginScope(this ILogger logger, params (string Key, object Value)[] values) { return logger.BeginScope(values.Select(pair => new KeyValuePair(pair.Key, pair.Value))); } /// /// Begins a logical operation scope. /// /// The logger. /// The game context. /// An that ends the logical operation scope on dispose. public static IDisposable? BeginScope(this ILogger logger, IGameContext gameContext) { if (gameContext is IGameServerContext gameServerContext) { return logger.BeginScope("GameServer {id}", gameServerContext.Id); } return null; } }