/// <summary> /// Logs a transient exception. /// </summary> /// <param name="log">The log.</param> /// <param name="e">The exception.</param> /// <param name="activityId">The optional activity ID.</param> public static void LogTransient(this INeonLogger log, Exception e, string activityId = null) { if (log.IsLogTransientEnabled) { log.LogTransient(null, e, activityId); } }
/// <summary> /// Logs a transient message retrieved via a message function. /// </summary> /// <param name="log">The log.</param> /// <param name="messageFunc">The message function.</param> /// <param name="activityId">The optional activity ID.</param> /// <remarks> /// This method is intended mostly to enable the efficient use of interpolated C# strings. /// </remarks> public static void LogTransient(this INeonLogger log, Func <string> messageFunc, string activityId = null) { if (log.IsLogDebugEnabled) { log.LogTransient(messageFunc(), activityId); } }
/// <summary> /// Handles logging of transient exceptions by invoking any <see cref="OnTransient"/> /// event handlers and then logging the transient exception when none of the handlers /// indicated that they handled the event. /// </summary> /// <param name="e">The transient exception.</param> protected void LogTransient(Exception e) { if (OnTransient == null) { log?.LogTransient(e); } else { var args = new RetryTransientArgs(e); foreach (var handler in OnTransient.GetInvocationList()) { handler.DynamicInvoke(args); if (args.Handled) { return; } } log?.LogTransient(e); } }