コード例 #1
0
        /// <summary>
        /// Delivers the trace data to the underlying file.
        /// </summary>
        /// <param name="eventCache">The context information provided by <see cref="System.Diagnostics"/>.</param>
        /// <param name="source">The name of the trace source that delivered the trace data.</param>
        /// <param name="eventType">The type of event.</param>
        /// <param name="id">The id of the event.</param>
        /// <param name="data">The data to trace.</param>
        public override void TraceData(TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data)
        {
            if (header.Length > 0)
            {
                WriteLine(header);
            }

            if (data is LogEntry)
            {
                if (this.Formatter != null)
                {
                    base.WriteLine(this.Formatter.Format(data as LogEntry));
                }
                else
                {
                    base.TraceData(eventCache, source, eventType, id, data);
                }
                InstrumentationProvider.FireTraceListenerEntryWrittenEvent();
            }
            else
            {
                base.TraceData(eventCache, source, eventType, id, data);
            }

            if (footer.Length > 0)
            {
                WriteLine(footer);
            }
        }
コード例 #2
0
 /// <summary>
 /// Sends the traced object to its final destination through a <see cref="MessageQueue"/>.
 /// </summary>
 /// <param name="eventCache">The context information provided by <see cref="System.Diagnostics"/>.</param>
 /// <param name="source">The name of the trace source that delivered the trace data.</param>
 /// <param name="eventType">The type of event.</param>
 /// <param name="id">The id of the event.</param>
 /// <param name="data">The data to trace.</param>
 public override void TraceData(TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data)
 {
     if (data is LogEntry)
     {
         SendMessageToQueue(data as LogEntry);
         InstrumentationProvider.FireTraceListenerEntryWrittenEvent();
     }
     else if (data is string)
     {
         Write(data as string);
     }
     else
     {
         base.TraceData(eventCache, source, eventType, id, data);
     }
 }
コード例 #3
0
 /// <summary>
 /// Delivers the trace data as an email message.
 /// </summary>
 /// <param name="eventCache">The context information provided by <see cref="System.Diagnostics"/>.</param>
 /// <param name="source">The name of the trace source that delivered the trace data.</param>
 /// <param name="eventType">The type of event.</param>
 /// <param name="id">The id of the event.</param>
 /// <param name="data">The data to trace.</param>
 public override void TraceData(TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data)
 {
     if (data is LogEntry)
     {
         EmailMessage message = new EmailMessage(toAddress, fromAddress, subjectLineStarter, subjectLineEnder, smtpServer, smtpPort, data as LogEntry, this.Formatter);
         message.Send();
         InstrumentationProvider.FireTraceListenerEntryWrittenEvent();
     }
     else if (data is string)
     {
         Write(data);
     }
     else
     {
         base.TraceData(eventCache, source, eventType, id, data);
     }
 }
コード例 #4
0
        /// <summary>
        /// Formats the object to trace and forward the trace request to the wrapped listener with the formatted result.
        /// </summary>
        /// <remarks>
        /// Formatting is only performed if the object to trace is a <see cref="LogEntry"/> and the formatter is set.
        /// </remarks>
        /// <param name="eventCache">The context information.</param>
        /// <param name="source">The trace source.</param>
        /// <param name="severity">The severity.</param>
        /// <param name="id">The event id.</param>
        /// <param name="data">The object to trace.</param>
        public override void TraceData(TraceEventCache eventCache, string source, TraceEventType severity, int id, object data)
        {
            if (data is LogEntry)
            {
                if (this.Formatter != null)
                {
                    this.slaveListener.TraceData(eventCache, source, severity, id, this.Formatter.Format(data as LogEntry));
                }
                else
                {
                    this.slaveListener.TraceData(eventCache, source, severity, id, data);
                }

                InstrumentationProvider.FireTraceListenerEntryWrittenEvent();
            }
            else
            {
                this.slaveListener.TraceData(eventCache, source, severity, id, data);
            }
        }
コード例 #5
0
 /// <summary>
 /// Delivers the trace data to the underlying database.
 /// </summary>
 /// <param name="eventCache">The context information provided by <see cref="System.Diagnostics"/>.</param>
 /// <param name="source">The name of the trace source that delivered the trace data.</param>
 /// <param name="eventType">The type of event.</param>
 /// <param name="id">The id of the event.</param>
 /// <param name="data">The data to trace.</param>
 public override void TraceData(TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data)
 {
     if (data is LogEntry)
     {
         LogEntry logEntry = data as LogEntry;
         if (ValidateParameters(logEntry))
         {
             ExecuteStoredProcedure(logEntry);
         }
         InstrumentationProvider.FireTraceListenerEntryWrittenEvent();
     }
     else if (data is string)
     {
         Write(data as string);
     }
     else
     {
         base.TraceData(eventCache, source, eventType, id, data);
     }
 }
コード例 #6
0
        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;
            }

            LogEntry entry = data as LogEntry;

            if (entry != null)
            {
                WeblogEmailMessage message = new WeblogEmailMessage(_toAddress, _fromAddress, _subjectLineStarter, _subjectLineEnder, _smtpServer, _smtpPort, _enableSsl, _userName, _password, entry, Formatter);
                message.Send();
                InstrumentationProvider.FireTraceListenerEntryWrittenEvent();
            }
            else if (data is string)
            {
                Write(data);
            }
            else
            {
                base.TraceData(eventCache, source, eventType, id, data);
            }
        }