internal void TraceEvent(TraceEventType type, int code, string msdnTraceCode, string description, TraceRecord trace, Exception exception, object source)
        {
            TraceXPathNavigator navigator = null;

            try
            {
                if ((this.TraceSource != null) && this.HaveListeners)
                {
                    try
                    {
                        this.BuildTrace(type, msdnTraceCode, description, trace, exception, source, out navigator);
                    }
                    catch (PlainXmlWriter.MaxSizeExceededException)
                    {
                        StringTraceRecord record = new StringTraceRecord("TruncatedTraceId", msdnTraceCode);
                        this.TraceEvent(type, 0x2000c, GenerateMsdnTraceCode("System.ServiceModel.Diagnostics", "TraceTruncatedQuotaExceeded"), TraceSR.GetString("TraceCodeTraceTruncatedQuotaExceeded"), record, null, null);
                    }
                    this.TraceSource.TraceData(type, code, navigator);
                    if (this.calledShutdown)
                    {
                        this.TraceSource.Flush();
                    }
                    this.LastFailure = DateTime.MinValue;
                }
            }
            catch (Exception exception2)
            {
                if (Fx.IsFatal(exception2))
                {
                    throw;
                }
                this.LogTraceFailure((navigator == null) ? string.Empty : navigator.ToString(), exception2);
            }
        }
#pragma warning disable 56500
        internal void TraceEvent(TraceEventType type, int code, string msdnTraceCode, string description, TraceRecord trace, Exception exception, object source)
        {
#pragma warning disable 618
            Fx.Assert(exception == null || type <= TraceEventType.Information, "Exceptions should be traced at Information or higher");
            Fx.Assert(!string.IsNullOrEmpty(description), "All TraceCodes should have a description");
#pragma warning restore 618
            TraceXPathNavigator navigator = null;
            try
            {
#pragma warning disable 618
                if (this.TraceSource != null && this.HaveListeners)
#pragma warning restore 618
                {
                    try
                    {
                        BuildTrace(type, msdnTraceCode, description, trace, exception, source, out navigator);
                    }
                    catch (PlainXmlWriter.MaxSizeExceededException)
                    {
                        StringTraceRecord codeTraceRecord = new StringTraceRecord("TruncatedTraceId", msdnTraceCode);
                        this.TraceEvent(type, DiagnosticsTraceCode.TraceTruncatedQuotaExceeded, LegacyDiagnosticTrace.GenerateMsdnTraceCode("System.ServiceModel.Diagnostics", "TraceTruncatedQuotaExceeded"), TraceSR.GetString(TraceSR.TraceCodeTraceTruncatedQuotaExceeded), codeTraceRecord, null, null);
                    }
                    this.TraceSource.TraceData(type, code, navigator);
                    if (this.CalledShutdown)
                    {
                        this.TraceSource.Flush();
                    }
                    // Must have been a successful trace.
                    this.LastFailure = DateTime.MinValue;
                }
            }
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }
                LogTraceFailure(navigator == null ? string.Empty : navigator.ToString(), e);
            }
        }
Beispiel #3
0
 private static void DatagramSentOrReceived(NativeMsmqMessage.BufferProperty messageId, Message message, int traceCode, string traceDescription)
 {
     if (DiagnosticUtility.ShouldTraceVerbose)
     {
         Guid        guid         = MessageIdToGuid(messageId);
         UniqueId    id           = message.Headers.MessageId;
         TraceRecord extendedData = null;
         if (null == id)
         {
             extendedData = new StringTraceRecord("MSMQMessageId", guid.ToString());
         }
         else
         {
             Dictionary <string, string> dictionary2 = new Dictionary <string, string>(2);
             dictionary2.Add("MSMQMessageId", guid.ToString());
             dictionary2.Add("WCFMessageId", id.ToString());
             Dictionary <string, string> dictionary = dictionary2;
             extendedData = new DictionaryTraceRecord(dictionary);
         }
         TraceUtility.TraceEvent(TraceEventType.Verbose, traceCode, traceDescription, extendedData, null, null);
     }
 }
 static void DatagramSentOrReceived(NativeMsmqMessage.BufferProperty messageId, Message message, int traceCode, string traceDescription)
 {
     if (DiagnosticUtility.ShouldTraceVerbose)
     {
         Guid        msmqId   = MessageIdToGuid(messageId);
         UniqueId    indigoId = message.Headers.MessageId;
         TraceRecord record   = null;
         if (null == indigoId)
         {
             record = new StringTraceRecord("MSMQMessageId", msmqId.ToString());
         }
         else
         {
             Dictionary <string, string> dictionary = new Dictionary <string, string>(2)
             {
                 { "MSMQMessageId", msmqId.ToString() },
                 { "WCFMessageId", indigoId.ToString() }
             };
             record = new DictionaryTraceRecord(dictionary);
         }
         TraceUtility.TraceEvent(TraceEventType.Verbose, traceCode, traceDescription, record, null, null);
     }
 }