//------------------------------------------Scope------------------------------------------// /// <summary> /// Formats the message and creates a scope. /// </summary> /// <param name="loggingService">The <see cref="ILoggingService"/> to create the scope in.</param> /// <param name="messageFormat">Format string of the log message in message template format. Example: <code>"User {User} logged in from {Address}"</code></param> /// <param name="args">An object array that contains zero or more objects to format.</param> /// <returns>A disposable scope object. Can be null.</returns> /// <example> /// using(loggingService.BeginScope("Processing request from {Address}", address)) /// { /// } /// </example> public static Task <IDisposable> BeginScopeAsync( this ILoggingService loggingService, string messageFormat, params object[] args) { if (loggingService == null) { throw new ArgumentNullException(nameof(loggingService)); } return(loggingService.BeginScopeAsync(new FormattedLogValues(messageFormat, args))); }