/// <summary> /// Writes the specified entry to the log. /// </summary> /// <param name="entry">The entry to be written.</param> /// <remarks> /// All overloads of Write ultimately call this method. /// </remarks> public static void Write(LogEntry entry) { var handler = EntryPosted; if (handler == null) { return; } // prevent re-entrancy if (entry.HasBeenPosted) { return; } entry.HasBeenPosted = true; foreach (EventHandler <InstrumentationEventArgs> subscriber in EntryPosted.GetInvocationList()) { try { subscriber(typeof(Log), new InstrumentationEventArgs(entry)); } catch (Exception exceptionFromHandler) { exceptionFromHandler.RaiseErrorEvent(); if (exceptionFromHandler.ShouldThrow()) { throw; } } } }
public static void TrackEvent( string eventName = null, IDictionary <string, string> properties = null, IDictionary <string, double> measurements = null) { EntryPosted?.Invoke(typeof(TelemetryEventEntry), new InstrumentationEventArgs(eventName, properties, measurements)); }
/// <summary> /// Unsubscribes all subscribers to the <see cref="Log.EntryPosted" /> event. /// </summary> internal static void UnsubscribeAllFromEntryPosted() { var handler = EntryPosted; if (handler == null) { return; } var subscribers = EntryPosted.GetInvocationList(); foreach (var d in subscribers) { EntryPosted -= (d as EventHandler <InstrumentationEventArgs>); } }