Esempio n. 1
0
        internal void TraceData(
            TraceEventType eventType,
            int id,
            MsgEntry MsgEntry,
            TraceListenerFilter traceListenerFilter,
            TraceEventCache traceEventCache)
        {
            if (!ShouldTrace(eventType)) return;

            bool isTransfer = MsgEntry.Severity == TraceEventType.Transfer && MsgEntry.RelatedActivityId != null;

            foreach (TraceListener listener in traceListenerFilter.GetAvailableTraceListeners(traceListeners))
            {
                try
                {
                    if (!listener.IsThreadSafe) Monitor.Enter(listener);

                    if (!isTransfer)
                    {
                        listener.TraceData(traceEventCache, Name, eventType, id, MsgEntry);
                    }
                    else
                    {
                        listener.TraceTransfer(traceEventCache, Name, id, MsgEntry.Message, MsgEntry.RelatedActivityId.Value);
                    }
                    instrumentationProvider.FireTraceListenerEntryWrittenEvent();

                    if (this.AutoFlush)
                    {
                        listener.Flush();
                    }
                }
                finally
                {
                    if (!listener.IsThreadSafe) Monitor.Exit(listener);
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Writes trace data to the trace listeners in the <see cref="MsgSource.Listeners"/> collection that have not already been
 /// written to for tracing using the specified event type, event identifier, and trace data.
 /// </summary>
 /// <remarks>
 /// The <paramref name="traceListenerFilter"/> will be updated to reflect the trace listeners that were written to by the 
 /// <see cref="MsgSource"/>.
 /// </remarks>
 /// <param name="eventType">The value that specifies the type of event that caused the trace.</param>
 /// <param name="id">A numeric identifier for the event.</param>
 /// <param name="MsgEntry">The <see cref="MsgEntry"/> to trace.</param>
 /// <param name="traceListenerFilter">The filter for already written to trace listeners.</param>
 public void TraceData(TraceEventType eventType, int id, MsgEntry MsgEntry, TraceListenerFilter traceListenerFilter)
 {
     this.TraceData(eventType, id, MsgEntry, traceListenerFilter, new TraceEventCache());
 }