public override void TraceEvent(TraceEventCache?eventCache, string source, TraceEventType eventType, int id, string format, params object?[]?args) { foreach (var l in Listners) { l.TraceEvent(eventCache, source, eventType, id, format, args); } }
public override void TraceData(TraceEventCache?eventCache, string source, TraceEventType eventType, int id, params object?[]?data) { if (Filter != null && !Filter.ShouldTrace(eventCache, source, eventType, id, null, null, null, data)) { return; } WriteHeader(source, eventType, id, eventCache); InternalWrite("<TraceData>"); if (data != null) { for (int i = 0; i < data.Length; i++) { InternalWrite("<DataItem>"); if (data[i] != null) { WriteData(data[i] !); } InternalWrite("</DataItem>"); } } InternalWrite("</TraceData>"); WriteFooter(eventCache); }
public override bool ShouldTrace(TraceEventCache?cache, string source, TraceEventType eventType, int id, [StringSyntax(StringSyntaxAttribute.CompositeFormat)] string?formatOrMessage, object?[]?args, object?data1, object?[]?data) { ArgumentNullException.ThrowIfNull(source); return(string.Equals(_src, source)); }
public virtual void TraceData(TraceEventCache?eventCache, string source, TraceEventType eventType, int id, params object?[]?data) { if (Filter != null && !Filter.ShouldTrace(eventCache, source, eventType, id, null, null, null, data)) { return; } WriteHeader(source, eventType, id); StringBuilder sb = new StringBuilder(); if (data != null) { for (int i = 0; i < data.Length; i++) { if (i != 0) { sb.Append(", "); } if (data[i] != null) { sb.Append(data[i] !.ToString()); } } } WriteLine(sb.ToString()); WriteFooter(eventCache); }
public override void TraceData(TraceEventCache?eventCache, string source, TraceEventType eventType, int id, object?data) { foreach (var l in Listners) { l.TraceData(eventCache, source, eventType, id, data); } }
private void WriteFooter(TraceEventCache?eventCache) { if (eventCache == null) { return; } _indentLevel++; if (IsEnabled(TraceOptions.ProcessId)) { WriteLine("ProcessId=" + eventCache.ProcessId); } if (IsEnabled(TraceOptions.LogicalOperationStack)) { Write("LogicalOperationStack="); Stack operationStack = eventCache.LogicalOperationStack; bool first = true; foreach (object obj in operationStack) { if (!first) { Write(", "); } else { first = false; } Write(obj.ToString()); } WriteLine(string.Empty); } Span <char> stackBuffer = stackalloc char[128]; if (IsEnabled(TraceOptions.ThreadId)) { WriteLine("ThreadId=" + eventCache.ThreadId); } if (IsEnabled(TraceOptions.DateTime)) { WriteLine(string.Create(null, stackBuffer, $"DateTime={eventCache.DateTime:o}")); } if (IsEnabled(TraceOptions.Timestamp)) { WriteLine(string.Create(null, stackBuffer, $"Timestamp={eventCache.Timestamp}")); } if (IsEnabled(TraceOptions.Callstack)) { WriteLine("Callstack=" + eventCache.Callstack); } _indentLevel--; }
public override void TraceTransfer(TraceEventCache?eventCache, string source, int id, string?message, System.Guid relatedActivityId) { foreach (var l in Listners) { l.TraceTransfer(eventCache, source, id, message, relatedActivityId); } }
public override void TraceData(TraceEventCache?eventCache, string source, TraceEventType eventType, int id, params object?[]?data) { if (Filter != null && !Filter.ShouldTrace(eventCache, source, eventType, id, null, null, null, data)) { return; } WriteHeader(source, eventType, id); // first a delimiter for the message Write(Delimiter); // Use get_Delimiter if (data != null) { for (int i = 0; i < data.Length; i++) { if (i != 0) { Write(_secondaryDelim); } WriteEscaped(data[i]?.ToString()); } } Write(Delimiter); // Use get_Delimiter WriteFooter(eventCache); }
public override void TraceEvent(TraceEventCache?eventCache, string source, TraceEventType eventType, int id, string?message) { foreach (var l in Listners) { l.TraceEvent(eventCache, source, eventType, id, message); } }
/// <summary> /// Writes trace information, a message, and event information to the listener specific output. /// </summary> /// <param name="eventCache">A <see cref="T:System.Diagnostics.TraceEventCache"></see> 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"></see> values specifying the type of event that has caused the trace.</param> /// <param name="id">A numeric identifier for the event.</param> /// <param name="message">A message to write.</param> public override void TraceEvent(TraceEventCache?eventCache, string source, TraceEventType eventType, int id, string?message) { if (this.Rollbar == null || message == null || string.IsNullOrWhiteSpace(message)) { return; } // the code below is simplified way to report events to Rollbar API, // in production code we can do better job mapping the available event data // into proper Rollbar data body: var custom = new Dictionary <string, object?>(); if (eventCache != null) { custom["callStack"] = eventCache.Callstack; custom["logicalOperationStack"] = eventCache.LogicalOperationStack; custom["processID"] = eventCache.ProcessId; custom["threadID"] = eventCache.ThreadId; custom["timestamp"] = eventCache.Timestamp; custom["dateTime"] = eventCache.DateTime; custom["eventType"] = eventType; custom["eventMessage"] = message; if (!string.IsNullOrWhiteSpace(eventCache.Callstack) #pragma warning disable CA1307 // Specify StringComparison for clarity && (message.Contains("Exception: ") || (eventType == TraceEventType.Critical) || (eventType == TraceEventType.Error))) #pragma warning restore CA1307 // Specify StringComparison for clarity { DTOs.Body body = new DTOs.Body(new DTOs.Trace(eventCache.Callstack, message)); DTOs.Data data = new DTOs.Data(this.Rollbar.Config, body, custom); data.Level = RollbarTraceListener.Translate(eventType); this.Rollbar.Log(data); return; } } switch (eventType) { case TraceEventType.Critical: this.Rollbar.Critical(message, custom); break; case TraceEventType.Error: this.Rollbar.Error(message, custom); break; case TraceEventType.Warning: this.Rollbar.Warning(message, custom); break; case TraceEventType.Information: this.Rollbar.Info(message, custom); break; default: this.Rollbar.Critical(message, custom); break; } }
private void WriteFooter(TraceEventCache?eventCache) { if (eventCache == null) { return; } _indentLevel++; if (IsEnabled(TraceOptions.ProcessId)) { WriteLine("ProcessId=" + eventCache.ProcessId); } if (IsEnabled(TraceOptions.LogicalOperationStack)) { Write("LogicalOperationStack="); Stack operationStack = eventCache.LogicalOperationStack; bool first = true; foreach (object obj in operationStack) { if (!first) { Write(", "); } else { first = false; } Write(obj.ToString()); } WriteLine(string.Empty); } if (IsEnabled(TraceOptions.ThreadId)) { WriteLine("ThreadId=" + eventCache.ThreadId); } if (IsEnabled(TraceOptions.DateTime)) { WriteLine("DateTime=" + eventCache.DateTime.ToString("o", CultureInfo.InvariantCulture)); } if (IsEnabled(TraceOptions.Timestamp)) { WriteLine("Timestamp=" + eventCache.Timestamp); } if (IsEnabled(TraceOptions.Callstack)) { WriteLine("Callstack=" + eventCache.Callstack); } _indentLevel--; }
public override bool ShouldTrace(TraceEventCache?cache, string source, TraceEventType eventType, int id, string?formatOrMessage, object?[]?args, object?data1, object?[]?data) { if (source == null) { throw new ArgumentNullException(nameof(source)); } return(string.Equals(_src, source)); }
public override void TraceEvent(TraceEventCache?eventCache, string source, TraceEventType eventType, int id, string?message) { if (Filter != null && !Filter.ShouldTrace(eventCache, source, eventType, id, message, null, null, null)) { return; } WriteHeader(source, eventType, id, eventCache); WriteEscaped(message); WriteFooter(eventCache); }
public override void TraceEvent(TraceEventCache?eventCache, string source, TraceEventType eventType, int id, string?format, params object?[]?args) { if (Filter != null && !Filter.ShouldTrace(eventCache, source, eventType, id, format, args, null, null)) { return; } WriteHeader(source, eventType, id, eventCache); WriteEscaped(args != null && args.Length != 0 ? string.Format(CultureInfo.InvariantCulture, format !, args) : format); WriteFooter(eventCache); }
// All other TraceEvent methods come through this one. public virtual void TraceEvent(TraceEventCache?eventCache, string source, TraceEventType eventType, int id, string?message) { if (Filter != null && !Filter.ShouldTrace(eventCache, source, eventType, id, message)) { return; } WriteHeader(source, eventType, id); WriteLine(message); WriteFooter(eventCache); }
public virtual void TraceData(TraceEventCache?eventCache, string source, TraceEventType eventType, int id, params object?[]?data) { if (Filter != null && !Filter.ShouldTrace(eventCache, source, eventType, id, null, null, null, data)) { return; } WriteHeader(source, eventType, id); WriteLine(data != null ? string.Join(", ", data) : string.Empty); WriteFooter(eventCache); }
public override void TraceEvent( TraceEventCache?cache, string source, TraceEventType type, int id, string?message) { var s = new StringBuilder( type switch { TraceEventType.Error => "!!", TraceEventType.Warning => "-!", _ => "--" });
private void WriteFooter(TraceEventCache?eventCache) { if (eventCache != null) { if (IsEnabled(TraceOptions.ProcessId)) { Write(eventCache.ProcessId.ToString(CultureInfo.InvariantCulture)); } Write(Delimiter); // Use get_Delimiter if (IsEnabled(TraceOptions.LogicalOperationStack)) { WriteStackEscaped(eventCache.LogicalOperationStack); } Write(Delimiter); // Use get_Delimiter if (IsEnabled(TraceOptions.ThreadId)) { WriteEscaped(eventCache.ThreadId); } Write(Delimiter); // Use get_Delimiter if (IsEnabled(TraceOptions.DateTime)) { WriteEscaped(eventCache.DateTime.ToString("o", CultureInfo.InvariantCulture)); } Write(Delimiter); // Use get_Delimiter if (IsEnabled(TraceOptions.Timestamp)) { Write(eventCache.Timestamp.ToString(CultureInfo.InvariantCulture)); } Write(Delimiter); // Use get_Delimiter if (IsEnabled(TraceOptions.Callstack)) { WriteEscaped(eventCache.Callstack); } } else { for (int i = 0; i < 5; i++) { Write(Delimiter); // Use get_Delimiter } } WriteLine(""); }
public override void TraceEvent(TraceEventCache?eventCache, string source, TraceEventType eventType, int id, string?message) { if (Filter != null && !Filter.ShouldTrace(eventCache, source, eventType, id, message, null, null, null)) { return; } WriteHeader(source, eventType, id); WriteEscaped(message); Write(Delimiter); // Use get_Delimiter // one more delimiter for the data object Write(Delimiter); // Use get_Delimiter WriteFooter(eventCache); }
public override void TraceData(TraceEventCache?eventCache, string source, TraceEventType eventType, int id, object?data) { if (Filter != null && !Filter.ShouldTrace(eventCache, source, eventType, id, null, null, data, null)) { return; } WriteHeader(source, eventType, id); // first a delimiter for the message Write(Delimiter); // Use get_Delimiter WriteEscaped(data?.ToString()); Write(Delimiter); // Use get_Delimiter WriteFooter(eventCache); }
// new write methods used by TraceSource public virtual void TraceData(TraceEventCache?eventCache, string source, TraceEventType eventType, int id, object?data) { if (Filter != null && !Filter.ShouldTrace(eventCache, source, eventType, id, null, null, data)) { return; } WriteHeader(source, eventType, id); string?datastring = string.Empty; if (data != null) { datastring = data.ToString(); } WriteLine(datastring); WriteFooter(eventCache); }
public virtual void TraceEvent(TraceEventCache?eventCache, string source, TraceEventType eventType, int id, [StringSyntax(StringSyntaxAttribute.CompositeFormat)] string?format, params object?[]?args) { if (Filter != null && !Filter.ShouldTrace(eventCache, source, eventType, id, format, args)) { return; } WriteHeader(source, eventType, id); if (args != null) { WriteLine(string.Format(CultureInfo.InvariantCulture, format !, args)); } else { WriteLine(format); } WriteFooter(eventCache); }
public override void TraceData(TraceEventCache?eventCache, string source, TraceEventType eventType, int id, object?data) { if (Filter != null && !Filter.ShouldTrace(eventCache, source, eventType, id, null, null, data, null)) { return; } WriteHeader(source, eventType, id, eventCache); InternalWrite("<TraceData>"); if (data != null) { InternalWrite("<DataItem>"); WriteData(data); InternalWrite("</DataItem>"); } InternalWrite("</TraceData>"); WriteFooter(eventCache); }
public override void TraceEvent(TraceEventCache?eventCache, string source, TraceEventType eventType, int id, string format, params object?[]?args) { base.TraceEvent(eventCache, source, eventType, id, format, args); if (format.StartsWith("Storyboard has begun;") && args != null) { if (args[1] is TriggerTraceStoryboard storyboard) { // add a breakpoint here to see when your trigger has been // entered or exited // the element being acted upon object?targetElement = args[5]; TriggerBase triggerBase = storyboard.TriggerBase; string triggerName = GetTriggerName(storyboard.TriggerBase); Debug.WriteLine("Element: {0}, {1}: {2}: {3}", targetElement, triggerBase.GetType().Name, triggerName, storyboard.StoryboardType); } } }
public override void TraceEvent(TraceEventCache?eventCache, string source, TraceEventType eventType, int id, string format, params object?[]?args) { if (Filter != null && !Filter.ShouldTrace(eventCache, source, eventType, id, format, args, null, null)) { return; } WriteHeader(source, eventType, id); if (args != null) { WriteEscaped(string.Format(CultureInfo.InvariantCulture, format, args)); } else { WriteEscaped(format); } Write(Delimiter); // Use get_Delimiter // one more delimiter for the data object Write(Delimiter); // Use get_Delimiter WriteFooter(eventCache); }
public virtual void TraceEvent(TraceEventCache?eventCache, string source, TraceEventType eventType, int id) { TraceEvent(eventCache, source, eventType, id, string.Empty); }
public virtual void TraceTransfer(TraceEventCache?eventCache, string source, int id, string?message, Guid relatedActivityId) { TraceEvent(eventCache, source, TraceEventType.Transfer, id, string.Create(null, stackalloc char[256], $"{message}, relatedActivityId={relatedActivityId}")); }
internal bool ShouldTrace(TraceEventCache?cache, string source, TraceEventType eventType, int id, string?formatOrMessage, object?[]?args, object?data1) { return(ShouldTrace(cache, source, eventType, id, formatOrMessage, args, data1, null)); }
internal bool ShouldTrace(TraceEventCache?cache, string source, TraceEventType eventType, int id, string?formatOrMessage) { return(ShouldTrace(cache, source, eventType, id, formatOrMessage, null, null, null)); }
public abstract bool ShouldTrace(TraceEventCache?cache, string source, TraceEventType eventType, int id, string?formatOrMessage, object?[]?args, object?data1, object?[]?data);