internal static void TraceEvent(TraceEventType type, string code, string description, TraceRecord trace, Exception exception, ref Guid activityId, bool emitTransfer, object source)
 {
     if (ShouldTrace(type))
     {
         using (Activity.CreateActivity(activityId, emitTransfer))
         {
             XPathNavigator data = BuildTraceString(type, code, description, trace, exception, source);
             try
             {
                 TraceSource.TraceData(type, 0, data);
                 if (calledShutdown)
                 {
                     TraceSource.Flush();
                 }
             }
             catch (OutOfMemoryException)
             {
                 throw;
             }
             catch (StackOverflowException)
             {
                 throw;
             }
             catch (ThreadAbortException)
             {
                 throw;
             }
             catch (Exception exception2)
             {
                 LogTraceFailure(System.Transactions.SR.GetString("TraceFailure", new object[] { type.ToString(), code, description, (source == null) ? string.Empty : CreateSourceString(source) }), exception2);
             }
         }
     }
 }
Example #2
0
 internal static void TraceEvent(TraceEventType type, string code, string description, TraceRecord trace, Exception exception, ref Guid activityId, bool emitTransfer, object source)
 {
     if (ShouldTrace(type))
     {
         using (Activity.CreateActivity(activityId, emitTransfer))
         {
             XPathNavigator navigator = BuildTraceString(type, code, description, trace, exception, source);
             try
             {
                 TraceSource.TraceData(type, 0, navigator);
                 if (s_calledShutdown)
                 {
                     TraceSource.Flush();
                 }
             }
             catch (OutOfMemoryException)
             {
                 throw;
             }
             catch (Exception e)
             {
                 string traceString = SR.Format(SR.TraceFailure,
                                                type.ToString(),
                                                code,
                                                description,
                                                source == null ? string.Empty : CreateSourceString(source));
                 LogTraceFailure(traceString, e);
             }
         }
     }
 }
Example #3
0
        static internal void TraceEvent(TraceEventType type, string code, string description, TraceRecord trace, Exception exception, ref Guid activityId, bool emitTransfer, object source)
        {
#if DEBUG
            Debug.Assert(exception == null || type <= TraceEventType.Information);
            Debug.Assert(!string.IsNullOrEmpty(description), "All TraceCodes should have a description");
#endif
            if (DiagnosticTrace.ShouldTrace(type))
            {
                using (Activity.CreateActivity(activityId, emitTransfer))
                {
                    XPathNavigator navigator = BuildTraceString(type, code, description, trace, exception, source);
                    try
                    {
                        DiagnosticTrace.TraceSource.TraceData(type, 0, navigator);
                        if (DiagnosticTrace.calledShutdown)
                        {
                            DiagnosticTrace.TraceSource.Flush();
                        }
                    }
                    catch (OutOfMemoryException)
                    {
                        throw;
                    }
                    catch (StackOverflowException)
                    {
                        throw;
                    }
                    catch (ThreadAbortException)
                    {
                        throw;
                    }
                    catch (Exception e)
                    {
                        string traceString = SR.GetString(SR.TraceFailure,
                                                          type.ToString(),
                                                          code,
                                                          description,
                                                          source == null ? string.Empty : DiagnosticTrace.CreateSourceString(source));
                        LogTraceFailure(traceString, e);
                    }
                }
            }
        }