Ejemplo n.º 1
0
        /// <summary>
        /// This is the main method that write the messages to the trace.
        /// All derived classes must use this method to write to the provider log.
        /// </summary>
        /// <param name="ed">EventDescriptor</param>
        /// <param name="payload">payload</param>
        protected void WriteEvent(EventDescriptor ed, params object[] payload)
        {
            EventProvider provider = GetProvider();

            if (!provider.IsEnabled())
            {
                return;
            }

            if (payload != null)
            {
                for (int i = 0; i < payload.Length; i++)
                {
                    if (payload[i] == null)
                    {
                        payload[i] = string.Empty;
                    }
                }
            }

            bool success = provider.WriteEvent(ref ed, payload);

            if (EventWritten != null)
            {
                EventWritten.Invoke(this, new EtwEventArgs(ed, success, payload));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Increases the number of messages.
        /// </summary>
        /// <param name="logEvent">The logging event.</param>
        protected override void Write(LogEventInfo logEvent)
        {
            if (BeforeWrite != null)
            {
                BeforeWrite.Invoke(null, null, Thread.CurrentThread.ManagedThreadId);
            }

            if (EventWritten != null)
            {
                var rendered = Layout == null ? null : Layout.Render(logEvent);
                EventWritten.Invoke(logEvent, rendered, Thread.CurrentThread.ManagedThreadId);
            }
        }