internal static void TraceEvent(TraceEventType type, string code, string description, TraceRecord trace, Exception exception)
 {
     TraceEvent(type, code, description, trace, exception, ref EmptyGuid, false, null);
 }
 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);
             }
         }
     }
 }
 private static void LogEvent(TraceEventType type, string code, string description, TraceRecord trace, Exception exception, object source)
 {
     StringBuilder builder = new StringBuilder(System.Transactions.SR.GetString("EventLogValue", new object[] { ProcessName, ProcessId.ToString(CultureInfo.CurrentCulture), code, description }));
     if (source != null)
     {
         builder.AppendLine(System.Transactions.SR.GetString("EventLogSourceValue", new object[] { CreateSourceString(source) }));
     }
     if (exception != null)
     {
         builder.AppendLine(System.Transactions.SR.GetString("EventLogExceptionValue", new object[] { exception.ToString() }));
     }
     if (trace != null)
     {
         builder.AppendLine(System.Transactions.SR.GetString("EventLogEventIdValue", new object[] { trace.EventId }));
         builder.AppendLine(System.Transactions.SR.GetString("EventLogTraceValue", new object[] { trace.ToString() }));
     }
     LogEvent(type, builder.ToString(), false);
 }
 internal static void TraceAndLogEvent(TraceEventType type, string code, string description, TraceRecord trace, Exception exception, ref Guid activityId, object source)
 {
     bool flag = ShouldTrace(type);
     string traceString = null;
     try
     {
         LogEvent(type, code, description, trace, exception, source);
         if (flag)
         {
             TraceEvent(type, code, description, trace, exception, ref activityId, false, source);
         }
     }
     catch (OutOfMemoryException)
     {
         throw;
     }
     catch (StackOverflowException)
     {
         throw;
     }
     catch (ThreadAbortException)
     {
         throw;
     }
     catch (Exception exception2)
     {
         LogTraceFailure(traceString, exception2);
     }
 }
 internal static void TraceEvent(TraceEventType type, string code, string description, TraceRecord trace, Exception exception)
 {
     TraceEvent(type, code, description, trace, exception, ref EmptyGuid, false, null);
 }
Exemplo n.º 6
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);
             }
         }
     }
 }
        static void LogEvent(TraceEventType type, string code, string description, TraceRecord trace, Exception exception, object source)
        {
            StringBuilder traceString = new StringBuilder(SR.GetString(SR.EventLogValue,
                DiagnosticTrace.ProcessName,
                DiagnosticTrace.ProcessId.ToString(CultureInfo.CurrentCulture),
                code,
                description));
            if (source != null)
            {
                traceString.AppendLine(SR.GetString(SR.EventLogSourceValue, DiagnosticTrace.CreateSourceString(source)));
            }

            if (exception != null)
            {
                traceString.AppendLine(SR.GetString(SR.EventLogExceptionValue, exception.ToString()));
            }

            if (trace != null)
            {
                traceString.AppendLine(SR.GetString(SR.EventLogEventIdValue, trace.EventId));
                traceString.AppendLine(SR.GetString(SR.EventLogTraceValue, trace.ToString()));
            }

            LogEvent(type, traceString.ToString(), false);
        }
        private static void LogEvent(TraceEventType type, string code, string description, TraceRecord trace, Exception exception, object source)
        {
            StringBuilder builder = new StringBuilder(System.Transactions.SR.GetString("EventLogValue", new object[] { ProcessName, ProcessId.ToString(CultureInfo.CurrentCulture), code, description }));

            if (source != null)
            {
                builder.AppendLine(System.Transactions.SR.GetString("EventLogSourceValue", new object[] { CreateSourceString(source) }));
            }
            if (exception != null)
            {
                builder.AppendLine(System.Transactions.SR.GetString("EventLogExceptionValue", new object[] { exception.ToString() }));
            }
            if (trace != null)
            {
                builder.AppendLine(System.Transactions.SR.GetString("EventLogEventIdValue", new object[] { trace.EventId }));
                builder.AppendLine(System.Transactions.SR.GetString("EventLogTraceValue", new object[] { trace.ToString() }));
            }
            LogEvent(type, builder.ToString(), false);
        }
 static internal void TraceEvent(TraceEventType type, string code, string description, TraceRecord trace, Exception exception)
 {
     DiagnosticTrace.TraceEvent(type, code, description, trace, exception, ref DiagnosticTrace.EmptyGuid, false, null);
 }
Exemplo n.º 10
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);
                    }
                }
            }
        }
Exemplo n.º 11
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);
                    }
                }
            }
        }
Exemplo n.º 12
0
 static internal void TraceEvent(TraceEventType type, string code, string description, TraceRecord trace, Exception exception)
 {
     DiagnosticTrace.TraceEvent(type, code, description, trace, exception, ref DiagnosticTrace.EmptyGuid, false, null);
 }
Exemplo n.º 13
0
        private static void LogEvent(TraceEventType type, string code, string description, TraceRecord trace, Exception exception, object source)
        {
            StringBuilder traceString = new StringBuilder(SR.Format(SR.EventLogValue,
                                                                    ProcessName,
                                                                    ProcessId.ToString(CultureInfo.CurrentCulture),
                                                                    code,
                                                                    description));

            if (source != null)
            {
                traceString.AppendLine(SR.Format(SR.EventLogSourceValue, CreateSourceString(source)));
            }

            if (exception != null)
            {
                traceString.AppendLine(SR.Format(SR.EventLogExceptionValue, exception.ToString()));
            }

            if (trace != null)
            {
                traceString.AppendLine(SR.Format(SR.EventLogEventIdValue, trace.EventId));
                traceString.AppendLine(SR.Format(SR.EventLogTraceValue, trace.ToString()));
            }

            LogEvent(type, traceString.ToString(), false);
        }
 private static XPathNavigator BuildTraceString(TraceEventType type, string code, string description, TraceRecord trace, Exception exception, object source)
 {
     return(BuildTraceString(new PlainXmlWriter(), type, code, description, trace, exception, source));
 }
Exemplo n.º 15
0
        static XPathNavigator BuildTraceString(PlainXmlWriter xml,
                                       TraceEventType type,
                                       string code,
                                       string description,
                                       TraceRecord trace,
                                       Exception exception,
                                       object source)
        {
            xml.WriteStartElement(DiagnosticStrings.TraceRecordTag);
            xml.WriteAttributeString(DiagnosticStrings.NamespaceTag, DiagnosticTrace.TraceRecordVersion);
            xml.WriteAttributeString(DiagnosticStrings.SeverityTag, DiagnosticTrace.LookupSeverity(type));

            xml.WriteElementString(DiagnosticStrings.TraceCodeTag, code);
            xml.WriteElementString(DiagnosticStrings.DescriptionTag, description);
            xml.WriteElementString(DiagnosticStrings.AppDomain, DiagnosticTrace.AppDomainFriendlyName);

            if (source != null)
            {
                xml.WriteElementString(DiagnosticStrings.SourceTag, DiagnosticTrace.CreateSourceString(source));
            }

            if (trace != null)
            {
                xml.WriteStartElement(DiagnosticStrings.ExtendedDataTag);
                xml.WriteAttributeString(DiagnosticStrings.NamespaceTag, trace.EventId);

                trace.WriteTo(xml);

                xml.WriteEndElement();
            }

            if (exception != null)
            {
                xml.WriteStartElement(DiagnosticStrings.ExceptionTag);
                DiagnosticTrace.AddExceptionToTraceString(xml, exception);
                xml.WriteEndElement();
            }

            xml.WriteEndElement();

            return xml.ToNavigator();
        }
 private static XPathNavigator BuildTraceString(PlainXmlWriter xml, TraceEventType type, string code, string description, TraceRecord trace, Exception exception, object source)
 {
     xml.WriteStartElement("TraceRecord");
     xml.WriteAttributeString("xmlns", "http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord");
     xml.WriteAttributeString("Severity", LookupSeverity(type));
     xml.WriteElementString("TraceIdentifier", code);
     xml.WriteElementString("Description", description);
     xml.WriteElementString("AppDomain", AppDomainFriendlyName);
     if (source != null)
     {
         xml.WriteElementString("Source", CreateSourceString(source));
     }
     if (trace != null)
     {
         xml.WriteStartElement("ExtendedData");
         xml.WriteAttributeString("xmlns", trace.EventId);
         trace.WriteTo(xml);
         xml.WriteEndElement();
     }
     if (exception != null)
     {
         xml.WriteStartElement("Exception");
         AddExceptionToTraceString(xml, exception);
         xml.WriteEndElement();
     }
     xml.WriteEndElement();
     return(xml.ToNavigator());
 }
 private static XPathNavigator BuildTraceString(TraceEventType type, string code, string description, TraceRecord trace, Exception exception, object source)
 {
     return BuildTraceString(new PlainXmlWriter(), type, code, description, trace, exception, source);
 }
        internal static void TraceAndLogEvent(TraceEventType type, string code, string description, TraceRecord trace, Exception exception, ref Guid activityId, object source)
        {
            bool   flag        = ShouldTrace(type);
            string traceString = null;

            try
            {
                LogEvent(type, code, description, trace, exception, source);
                if (flag)
                {
                    TraceEvent(type, code, description, trace, exception, ref activityId, false, source);
                }
            }
            catch (OutOfMemoryException)
            {
                throw;
            }
            catch (StackOverflowException)
            {
                throw;
            }
            catch (ThreadAbortException)
            {
                throw;
            }
            catch (Exception exception2)
            {
                LogTraceFailure(traceString, exception2);
            }
        }
 private static XPathNavigator BuildTraceString(PlainXmlWriter xml, TraceEventType type, string code, string description, TraceRecord trace, Exception exception, object source)
 {
     xml.WriteStartElement("TraceRecord");
     xml.WriteAttributeString("xmlns", "http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord");
     xml.WriteAttributeString("Severity", LookupSeverity(type));
     xml.WriteElementString("TraceIdentifier", code);
     xml.WriteElementString("Description", description);
     xml.WriteElementString("AppDomain", AppDomainFriendlyName);
     if (source != null)
     {
         xml.WriteElementString("Source", CreateSourceString(source));
     }
     if (trace != null)
     {
         xml.WriteStartElement("ExtendedData");
         xml.WriteAttributeString("xmlns", trace.EventId);
         trace.WriteTo(xml);
         xml.WriteEndElement();
     }
     if (exception != null)
     {
         xml.WriteStartElement("Exception");
         AddExceptionToTraceString(xml, exception);
         xml.WriteEndElement();
     }
     xml.WriteEndElement();
     return xml.ToNavigator();
 }
 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);
             }
         }
     }
 }
Exemplo n.º 21
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);
             }
         }
     }
 }