public override void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id, string message) { base.TraceEvent(eventCache, source, eventType, id, message); var traceEvent = new TraceEventMessage { CallStack = eventCache.Callstack, DateTime = eventCache.DateTime, Message = $"{message}", ProcessId = eventCache.ProcessId, Source = source, ThreadId = eventCache.ThreadId, Timestamp = eventCache.Timestamp, TraceEventType = eventType, ApplicationTitle = _applicationTitle }; var regexObj = new Regex(@"(?<Location>[^.]*)\.(?<Method>[^(]*)\((?<Ln>[\d]*)\): (?<Action>[^(]*)\((?<Value>.*)\)", RegexOptions.Singleline); traceEvent.Location = regexObj.Match(traceEvent.Message).Groups["Location"].Value; traceEvent.Method = regexObj.Match(traceEvent.Message).Groups["Method"].Value; traceEvent.Value = regexObj.Match(traceEvent.Message).Groups["Value"].Value; traceEvent.Action = regexObj.Match(traceEvent.Message).Groups["Action"].Value; if (!string.IsNullOrEmpty(traceEvent.Action)) { if (Enum.TryParse(traceEvent.Action, out RXAction rxAction)) { traceEvent.RXAction = rxAction; } } traceEvent.Line = Convert.ToInt32(regexObj.Match(traceEvent.Message).Groups["Ln"].Value); traceEvent.LogicalOperationStack = string.Join(Environment.NewLine, eventCache.LogicalOperationStack.ToArray()); _eventTraceSubject.OnNext(traceEvent); }
public static void MapTo(this TraceEvent traceEvent, TraceEventMessage mapToEvent) { foreach (var memberSetter in MemberSetters) { var propertyValue = traceEvent.GetPropertyValue(memberSetter.Key); memberSetter.Value.Invoke(mapToEvent, propertyValue); } }
// public static IObservable<ITraceEvent> TraceEvent => TraceEventSubject.CountSubsequent(_ => _.TraceKey()).UpdateTraceCalls(); public static void TraceMessage(this TraceSource traceSource, string value, TraceEventType traceEventType = TraceEventType.Information) { var traceEventMessage = new TraceEventMessage { Location = nameof(ReactiveLoggerService), Method = nameof(TraceMessage), RXAction = RXAction.None, Value = value, TraceEventType = traceEventType }; if (traceSource.Switch.Level != SourceLevels.Off) { traceSource.TraceEventMessage(traceEventMessage); } }
protected override void WriteTrace(TraceEventCache eventCache, string source, TraceEventType eventType, int id, string message, Guid?relatedActivityId, object[] data) { if (!_isDisposed && !DisableFileWriter) { base.WriteTrace(eventCache, message, eventType, id, message, relatedActivityId, data); } var traceEvent = new TraceEventMessage { CallStack = eventCache.Callstack, DateTime = eventCache.DateTime, Message = $"{message}", ProcessId = eventCache.ProcessId, Source = source, ThreadId = eventCache.ThreadId, Timestamp = eventCache.Timestamp, TraceEventType = eventType, ApplicationTitle = _applicationTitle, }; var match = Regex.Match(traceEvent.Message); traceEvent.Location = match.Groups["Location"].Value; traceEvent.Method = match.Groups["Method"].Value; traceEvent.Value = match.Groups["Value"].Value; traceEvent.Action = match.Groups["Action"].Value; if (!string.IsNullOrEmpty(traceEvent.Action)) { if (Enum.TryParse(traceEvent.Action, out RXAction rxAction)) { traceEvent.RXAction = rxAction; } } if (traceEvent.RXAction == RXAction.OnNext) { traceEvent.ResultType = traceEvent.Method.Substring(traceEvent.Method.IndexOf(">", StringComparison.Ordinal) + 1); traceEvent.Method = traceEvent.Method.Substring(0, traceEvent.Method.IndexOf(" ", StringComparison.Ordinal)); } var value = match.Groups["Ln"].Value; if (!string.IsNullOrEmpty(value)) { traceEvent.Line = Convert.ToInt32(value); } traceEvent.LogicalOperationStack = string.Join(Environment.NewLine, eventCache.LogicalOperationStack.ToArray()); _eventTraceSubject.OnNext(traceEvent); }