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);
     }
 }
コード例 #5
0
 internal static void TraceEvent(TraceEventType type, string code, string description, TraceRecord trace, Exception exception)
 {
     TraceEvent(type, code, description, trace, exception, ref EmptyGuid, false, null);
 }
コード例 #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);
             }
         }
     }
 }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
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);
 }
コード例 #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);
                    }
                }
            }
        }
コード例 #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);
                    }
                }
            }
        }
コード例 #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);
 }
コード例 #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);
        }
コード例 #14
0
 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));
 }
コード例 #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();
        }
コード例 #16
0
 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());
 }
コード例 #17
0
 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);
 }
コード例 #18
0
        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);
            }
        }
コード例 #19
0
 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();
 }
コード例 #20
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 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);
             }
         }
     }
 }
コード例 #21
0
ファイル: DiagnosticTrace.cs プロジェクト: geoffkizer/corefx
 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);
             }
         }
     }
 }