protected override void OnEventWritten(EventWrittenEventArgs eventSourceEvent)
        {
            var metadata = new EventMetaData
            {
                Keywords = (long)eventSourceEvent.Keywords,
                MessageFormat = eventSourceEvent.Message,
                EventId = eventSourceEvent.EventId,
                Level = eventSourceEvent.Level
            };

            var traceEvent = new TraceEvent
            {
                MetaData = metadata,
                Payload = eventSourceEvent.Payload != null ? eventSourceEvent.Payload.ToArray() : null
            };

            this.listener.WriteEvent(traceEvent);
        }
        protected override void OnEventWritten(EventWrittenEventArgs eventSourceEvent)
        {
            var metadata = new EventMetaData
            {
                Keywords      = (long)eventSourceEvent.Keywords,
                MessageFormat = eventSourceEvent.Message,
                EventId       = eventSourceEvent.EventId,
                Level         = eventSourceEvent.Level
            };

            var traceEvent = new TraceEvent
            {
                MetaData = metadata,
                Payload  = eventSourceEvent.Payload != null?eventSourceEvent.Payload.ToArray() : null
            };

            this.listener.WriteEvent(traceEvent);
        }
예제 #3
0
        private void InitializeMetadataCollection()
        {
            var publicMethodsInfos = this.GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);

            if (publicMethodsInfos.Length > 0)
            {
                this.metadataCollection = new Dictionary <int, EventMetaData>(publicMethodsInfos.Length);

                foreach (var publicMethodsInfo in publicMethodsInfos)
                {
                    var attributes = publicMethodsInfo.GetCustomAttributes(typeof(EventAttribute), false).ToArray();

                    if (attributes.Length == 1)
                    {
                        var attribute = (EventAttribute)attributes[0];

                        var metadata = new EventMetaData
                        {
                            EventId       = attribute.EventId,
                            Keywords      = (long)attribute.Keywords,
                            Level         = attribute.Level,
                            MessageFormat = attribute.Message
                        };

                        if (!this.metadataCollection.ContainsKey(metadata.EventId))
                        {
                            this.metadataCollection.Add(metadata.EventId, metadata);
                        }
#if DEBUG
                        else
                        {
                            throw new InvalidDataException("Multiple event methods with same id: " + metadata.EventId);
                        }
#endif
                    }
                }
            }
        }
예제 #4
0
        protected override void OnEventWritten(EventWrittenEventArgs eventSourceEvent)
        {
            if (eventSourceEvent == null)
            {
                return;
            }

            var metadata = new EventMetaData
            {
                EventSourceName = eventSourceEvent.EventSource?.Name,
                Keywords        = (long)eventSourceEvent.Keywords,
                MessageFormat   = eventSourceEvent.Message,
                EventId         = eventSourceEvent.EventId,
                Level           = eventSourceEvent.Level
            };

            var traceEvent = new TraceEvent
            {
                MetaData = metadata,
                Payload  = eventSourceEvent.Payload?.ToArray()
            };

            this.listener.WriteEvent(traceEvent);
        }
        private void InitializeMetadataCollection()
        {
            var publicMethodsInfos = this.GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);

            if (publicMethodsInfos.Length > 0)
            {
                this.metadataCollection = new Dictionary<int, EventMetaData>(publicMethodsInfos.Length);

                foreach (var publicMethodsInfo in publicMethodsInfos)
                {
                    var attributes = publicMethodsInfo.GetCustomAttributes(typeof(EventAttribute), false).ToArray();

                    if (attributes.Length == 1)
                    {
                        var attribute = (EventAttribute)attributes[0];

                        var metadata = new EventMetaData
                        {
                            EventId = attribute.EventId,
                            Keywords = (long)attribute.Keywords,
                            Level = attribute.Level,
                            MessageFormat = attribute.Message
                        };

                        if (!this.metadataCollection.ContainsKey(metadata.EventId))
                        {
                            this.metadataCollection.Add(metadata.EventId, metadata);
                        }
#if DEBUG
                        else
                        {
                            throw new InvalidDataException("Multiple event methods with same id: " + metadata.EventId);
                        }
#endif
                    }
                }
            }
        }