/// <summary> /// Flushes the output buffer asynchronously. /// </summary> /// <param name="reportError">The delegate to use to report errors while tracing asynchronously.</param> public void Flush(ReportTracingError reportError) { this.AddRequest(tl => { try { tl.Flush(); } catch (Exception e) { if (reportError != null) { reportError(e, null, ""); } else { throw; } } }); }
/// <summary> /// Writes trace information, a message, a related activity identity and event information to the listener specific output. /// </summary> /// <param name="eventCache">A <see cref="T:System.Diagnostics.TraceEventCache" /> object that contains the current process ID, thread ID, and stack trace information.</param> /// <param name="source">A name used to identify the output, typically the name of the application that generated the trace event.</param> /// <param name="id">A numeric identifier for the event.</param> /// <param name="message">A message to write.</param> /// <param name="relatedActivityId">A <see cref="T:System.Guid" /> object identifying a related activity.</param> /// <param name="reportError">The delegate to use to report errors while tracing asynchronously.</param> public void TraceTransfer(TraceEventCache eventCache, string source, int id, string message, Guid relatedActivityId, ReportTracingError reportError) { if (this.CheckFilter(eventCache, source, TraceEventType.Transfer, id, message, null, null, null)) { this.AddRequest(tl => { try { tl.TraceTransfer(eventCache, source, id, message, relatedActivityId); } catch (Exception e) { if (reportError != null) { reportError(e, message, source); } else { throw; } } }); } }
/// <summary> /// Writes trace information, a data object and event information to the listener specific output. /// </summary> /// <param name="eventCache">A <see cref="T:System.Diagnostics.TraceEventCache" /> object that contains the current process ID, thread ID, and stack trace information.</param> /// <param name="source">A name used to identify the output, typically the name of the application that generated the trace event.</param> /// <param name="eventType">One of the <see cref="T:System.Diagnostics.TraceEventType" /> values specifying the type of event that has caused the trace.</param> /// <param name="id">A numeric identifier for the event.</param> /// <param name="data">The trace data to emit.</param> /// <param name="reportError">The delegate to use to report errors while tracing asynchronously.</param> public void TraceData(TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data, ReportTracingError reportError) { if (this.CheckFilter(eventCache, source, eventType, id, null, null, data, null)) { CaptureContextInformation(data); this.AddRequest(tl => { try { tl.TraceData(eventCache, source, eventType, id, data); } catch (Exception e) { if (reportError != null) { reportError(e, data, source); } else { throw; } } }); } }
/// <summary> /// Flushes the output buffer asynchronously. /// </summary> /// <param name="reportError">The delegate to use to report errors while tracing asynchronously.</param> public void Flush(ReportTracingError reportError) { this.AddRequest(tl => { try { tl.Flush(); } catch (Exception e) { if (reportError != null) { reportError(e, null, ""); } else { throw; } } }); }
internal void TraceData( TraceEventType eventType, int id, LogEntry logEntry, TraceListenerFilter traceListenerFilter, TraceEventCache traceEventCache, ReportTracingError reportError) { if (!ShouldTrace(eventType)) { return; } bool isTransfer = logEntry.Severity == TraceEventType.Transfer && logEntry.RelatedActivityId != null; try { foreach (TraceListener listener in traceListenerFilter.GetAvailableTraceListeners(traceListeners)) { var asynchronousListener = listener as IAsynchronousTraceListener; if (asynchronousListener == null) { try { if (!listener.IsThreadSafe) { Monitor.Enter(listener); } if (!isTransfer) { listener.TraceData(traceEventCache, this.Name, eventType, id, logEntry); } else { listener.TraceTransfer(traceEventCache, this.Name, id, logEntry.Message, logEntry.RelatedActivityId.Value); } if (this.AutoFlush) { listener.Flush(); } } finally { if (!listener.IsThreadSafe) { Monitor.Exit(listener); } } } else { if (!isTransfer) { asynchronousListener.TraceData(traceEventCache, this.Name, eventType, id, logEntry, reportError); } else { asynchronousListener.TraceTransfer(traceEventCache, this.Name, id, logEntry.Message, logEntry.RelatedActivityId.Value, reportError); } if (this.AutoFlush) { asynchronousListener.Flush(reportError); } } } } catch (Exception e) { if (reportError == null) { throw; } reportError(e, logEntry, this.name); } }
/// <summary> /// Writes trace information, a message, a related activity identity and event information to the listener specific output. /// </summary> /// <param name="eventCache">A <see cref="T:System.Diagnostics.TraceEventCache" /> object that contains the current process ID, thread ID, and stack trace information.</param> /// <param name="source">A name used to identify the output, typically the name of the application that generated the trace event.</param> /// <param name="id">A numeric identifier for the event.</param> /// <param name="message">A message to write.</param> /// <param name="relatedActivityId">A <see cref="T:System.Guid" /> object identifying a related activity.</param> /// <param name="reportError">The delegate to use to report errors while tracing asynchronously.</param> public void TraceTransfer(TraceEventCache eventCache, string source, int id, string message, Guid relatedActivityId, ReportTracingError reportError) { if (this.CheckFilter(eventCache, source, TraceEventType.Transfer, id, message, null, null, null)) { this.AddRequest(tl => { try { tl.TraceTransfer(eventCache, source, id, message, relatedActivityId); } catch (Exception e) { if (reportError != null) { reportError(e, message, source); } else { throw; } } }); } }
/// <summary> /// Writes trace information, a data object and event information to the listener specific output. /// </summary> /// <param name="eventCache">A <see cref="T:System.Diagnostics.TraceEventCache" /> object that contains the current process ID, thread ID, and stack trace information.</param> /// <param name="source">A name used to identify the output, typically the name of the application that generated the trace event.</param> /// <param name="eventType">One of the <see cref="T:System.Diagnostics.TraceEventType" /> values specifying the type of event that has caused the trace.</param> /// <param name="id">A numeric identifier for the event.</param> /// <param name="data">The trace data to emit.</param> /// <param name="reportError">The delegate to use to report errors while tracing asynchronously.</param> public void TraceData(TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data, ReportTracingError reportError) { if (this.CheckFilter(eventCache, source, eventType, id, null, null, data, null)) { CaptureContextInformation(data); this.AddRequest(tl => { try { tl.TraceData(eventCache, source, eventType, id, data); } catch (Exception e) { if (reportError != null) { reportError(e, data, source); } else { throw; } } }); } }
internal void TraceData( TraceEventType eventType, int id, LogEntry logEntry, TraceListenerFilter traceListenerFilter, TraceEventCache traceEventCache, ReportTracingError reportError) { if (!ShouldTrace(eventType)) return; bool isTransfer = logEntry.Severity == TraceEventType.Transfer && logEntry.RelatedActivityId != null; try { foreach (TraceListener listener in traceListenerFilter.GetAvailableTraceListeners(traceListeners)) { var asynchronousListener = listener as IAsynchronousTraceListener; if (asynchronousListener == null) { try { if (!listener.IsThreadSafe) Monitor.Enter(listener); if (!isTransfer) { listener.TraceData(traceEventCache, this.Name, eventType, id, logEntry); } else { listener.TraceTransfer(traceEventCache, this.Name, id, logEntry.Message, logEntry.RelatedActivityId.Value); } if (this.AutoFlush) { listener.Flush(); } } finally { if (!listener.IsThreadSafe) Monitor.Exit(listener); } } else { if (!isTransfer) { asynchronousListener.TraceData(traceEventCache, this.Name, eventType, id, logEntry, reportError); } else { asynchronousListener.TraceTransfer(traceEventCache, this.Name, id, logEntry.Message, logEntry.RelatedActivityId.Value, reportError); } if (this.AutoFlush) { asynchronousListener.Flush(reportError); } } } } catch (Exception e) { if (reportError == null) { throw; } reportError(e, logEntry, this.name); } }