/// <summary> /// Writes a trace entry using enterpise library logging block. /// </summary> /// <param name="traceEntry">The <see cref="TraceEntry"/> that is to be written.</param> protected virtual void WriteEntry(TraceEntry traceEntry) { var entlibTraceEntry = new EntLib.LogEntry(); entlibTraceEntry.Message = traceEntry.Method + " " + traceEntry.Duration; entlibTraceEntry.Title = traceEntry.Operation; entlibTraceEntry.Categories.Add("Trace"); EntLib.Logger.Write(entlibTraceEntry); }
/// <summary> /// Initializes a new instance of the <see cref="Tracer"/> class with the specified operationName name and activityId. /// </summary> /// <param name="operationName">Identifies the name of the operation that is being traced.</param> /// <param name="activityId">Indicates the correlation activity id if it is required.</param> public Tracer(string operationName, Guid activityId) { if (!LoggerManager.Started) { throw new InvalidOperationException("Cannot perform a trace without first starting LoggerManager."); } this.startTime = DateTime.Now; this.entry = new TraceEntry { ActivityId = activityId, Operation = operationName, Method = GetExecutingMethodName() }; }