/// <inheritdoc cref="BeginActionScope(IWikiClientLoggable,object,IEnumerable,string)"/> public static IDisposable BeginActionScope(this IWikiClientLoggable loggable, object target, [CallerMemberName] string actionName = null) { if (loggable == null) { throw new ArgumentNullException(nameof(loggable)); } return(BeginActionScope(loggable, target, null, actionName)); }
/// <summary> /// Invokes <see cref="ILogger.BeginScope{TState}"/> on the <see cref="IWikiClientLoggable.Logger"/> /// with the current action(method) name and parameters. /// </summary> /// <param name="loggable">The instance whose <see cref="IWikiClientLoggable.Logger"/> will enter a new scope.</param> /// <param name="target">The action target. Usually the target <see cref="WikiSite"/>, <see cref="WikiPage"/>, etc. /// Can be <c>null</c>.</param> /// <param name="parameters">The action parameters. Can be <c>null</c>.</param> /// <param name="actionName">The action name. Leave it missing to use the caller's member name.</param> /// <returns>An <see cref="IDisposable"/> that when disposed, indicates the action is over.</returns> public static IDisposable BeginActionScope(this IWikiClientLoggable loggable, object target, IEnumerable parameters, [CallerMemberName] string actionName = null) { if (loggable == null) { throw new ArgumentNullException(nameof(loggable)); } if (loggable.Logger is NullLogger) { return(EmptyDisposable.Instance); } var outer = loggable.Logger.BeginScope(loggable); var inner = loggable.Logger.BeginScope(new ActionLogScopeState(target, actionName, parameters)); return(new CombinedDisposable(inner, outer)); }
/// <inheritdoc cref="BeginActionScope(IWikiClientLoggable,object,object,object,string)"/> public static IDisposable BeginActionScope(this IWikiClientLoggable loggable, object target, object param1, [CallerMemberName] string actionName = null) { return(BeginActionScope(loggable, target, new[] { param1 }, actionName)); }