public void Dispose() { if (!this.disposed) { if (this.args == null) { this.source.Trace(new MessageTraceEvent(TraceEventType.Stop, 0, this.displayName)); } else { this.source.Trace(new MessageTraceEvent(TraceEventType.Stop, 0, this.displayName, args)); } if (this.oldId != Guid.Empty) { if (this.args == null) { source.Trace(new TransferTraceEvent(this.oldId, this.newId + " > " + this.oldId, displayName)); } else { source.Trace(new TransferTraceEvent(this.oldId, this.newId + " > " + this.oldId, displayName, args)); } } Trace.CorrelationManager.ActivityId = this.oldId; } this.disposed = true; }
public TraceActivity(ITraceSource source, string format, params object[] args) { Guard.NotNullOrEmpty(() => format, format); Guard.NotNull(() => source, source); this.displayName = format; if (args != null && args.Length > 0) { this.args = args; } this.source = source; this.newId = Guid.NewGuid(); this.oldId = Trace.CorrelationManager.ActivityId; if (this.oldId != Guid.Empty) { if (this.args == null) { source.Trace(new TransferTraceEvent(this.newId, this.oldId + " > " + this.newId, displayName)); } else { source.Trace(new TransferTraceEvent(this.newId, this.oldId + " > " + this.newId, displayName, args)); } } Trace.CorrelationManager.ActivityId = newId; if (this.args == null) { this.source.Trace(new MessageTraceEvent(TraceEventType.Start, 0, this.displayName)); } else { this.source.Trace(new MessageTraceEvent(TraceEventType.Start, 0, this.displayName, args)); } }
public TraceActivity(ITraceSource source, string format, params object[] args) { Guard.NotNullOrEmpty(() => format, format); Guard.NotNull(() => source, source); this.displayName = format; if (args != null && args.Length > 0) this.args = args; this.source = source; this.newId = Guid.NewGuid(); this.oldId = Trace.CorrelationManager.ActivityId; if (this.oldId != Guid.Empty) { if (this.args == null) source.Trace(new TransferTraceEvent(this.newId, this.oldId + " > " + this.newId, displayName)); else source.Trace(new TransferTraceEvent(this.newId, this.oldId + " > " + this.newId, displayName, args)); } Trace.CorrelationManager.ActivityId = newId; if (this.args == null) this.source.Trace(new MessageTraceEvent(TraceEventType.Start, 0, this.displayName)); else this.source.Trace(new MessageTraceEvent(TraceEventType.Start, 0, this.displayName, args)); }
/// <summary> /// Traces an event of type <see cref="TraceEventType.Error"/> with the given exception, format string and arguments. /// </summary> public static void TraceError(this ITraceSource source, Exception exception, string format, params object[] args) { Guard.NotNull(() => source, source); source.Trace(new ExceptionTraceEvent(TraceEventType.Error, 0, exception, format, args)); }
/// <summary> /// Traces an event of type <see cref="TraceEventType.Error"/> with the given message; /// </summary> public static void TraceError(this ITraceSource source, string message) { Guard.NotNull(() => source, source); source.Trace(new MessageTraceEvent(TraceEventType.Error, 0, message)); }
/// <summary> /// Traces data with the given associated <see cref="TraceEventType"/>. /// </summary> public static void TraceData(this ITraceSource source, TraceEventType eventType, object data) { Guard.NotNull(() => source, source); source.Trace(new DataTraceEvent(eventType, 0, data)); }
/// <summary> /// Traces an event of type <see cref="TraceEventType.Verbose"/> with the given format string and arguments. /// </summary> public static void TraceVerbose(this ITraceSource source, string format, params object[] args) { Guard.NotNull(() => source, source); source.Trace(new MessageTraceEvent(TraceEventType.Verbose, 0, format, args)); }
/// <summary> /// Traces an event of type <see cref="TraceEventType.Error"/> with the given exception, using the /// <see cref="Exception.Message"/> as the trace event message. /// </summary> public static void TraceError(this ITraceSource source, Exception exception) { Guard.NotNull(() => source, source); source.Trace(new ExceptionTraceEvent(TraceEventType.Error, 0, exception)); }