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);
            }
        }
        private static void LogInternal(MessageLogTraceRecord record)
        {
            PlainXmlWriter writer = new PlainXmlWriter(MaxMessageSize);

            try
            {
                record.WriteTo(writer);
                writer.Close();
                TraceXPathNavigator data = writer.Navigator;
                if (((messageTraceSource != null) && !messageTraceSource.ShouldLogPii) || !LogKnownPii)
                {
                    data.RemovePii(PiiHeadersPaths);
                    if ((LogMessageBody && (record.Message != null)) && HasSecurityAction(record.Message))
                    {
                        data.RemovePii(PiiBodyPaths);
                    }
                }
                LogInternal(record.MessageLoggingSource, data);
            }
            catch (PlainXmlWriter.MaxSizeExceededException)
            {
                if (DiagnosticUtility.ShouldTraceWarning)
                {
                    TraceUtility.TraceEvent(TraceEventType.Warning, 0x2000b, System.ServiceModel.SR.GetString("TraceCodeMessageNotLoggedQuotaExceeded"), record.Message);
                }
            }
        }
        void BuildTrace(TraceEventType type, string msdnTraceCode, string description, TraceRecord trace,
                        Exception exception, object source, out TraceXPathNavigator navigator)
        {
            PlainXmlWriter xmlWriter = new PlainXmlWriter(LegacyDiagnosticTrace.MaxTraceSize);

            navigator = xmlWriter.Navigator;

            this.BuildTrace(xmlWriter, type, msdnTraceCode, description, trace, exception, source);

            if (!ShouldLogPii)
            {
                navigator.RemovePii(DiagnosticStrings.HeadersPaths);
            }
        }
#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);
            }
        }
Ejemplo n.º 5
0
        static void LogInternal(MessageLogTraceRecord record)
        {
            Fx.Assert(null != record, "record cannot be null");

            PlainXmlWriter xmlWriter = new PlainXmlWriter(MessageLogger.MaxMessageSize);

            try
            {
                record.WriteTo(xmlWriter);
                xmlWriter.Close();
                TraceXPathNavigator navigator = xmlWriter.Navigator;

                if ((MessageLogger.messageTraceSource != null &&
                     !MessageLogger.messageTraceSource.ShouldLogPii) ||
                    !MessageLogger.LogKnownPii)
                {
                    navigator.RemovePii(MessageLogger.PiiHeadersPaths);
                    if (MessageLogger.LogMessageBody && null != record.Message)
                    {
                        if (HasSecurityAction(record.Message))
                        {
                            navigator.RemovePii(MessageLogger.PiiBodyPaths);
                        }
                    }
                }

                LogInternal(record.MessageLoggingSource, navigator);
            }
            catch (PlainXmlWriter.MaxSizeExceededException)
            {
                if (DiagnosticUtility.ShouldTraceWarning)
                {
                    TraceUtility.TraceEvent(TraceEventType.Warning, TraceCode.MessageNotLoggedQuotaExceeded,
                                            SR.GetString(SR.TraceCodeMessageNotLoggedQuotaExceeded), record.Message);
                }
            }
        }
 private void BuildTrace(TraceEventType type, string msdnTraceCode, string description, TraceRecord trace, Exception exception, object source, out TraceXPathNavigator navigator)
 {
     PlainXmlWriter xml = new PlainXmlWriter(0xffff);
     navigator = xml.Navigator;
     this.BuildTrace(xml, type, msdnTraceCode, description, trace, exception, source);
     if (!this.TraceSource.ShouldLogPii)
     {
         navigator.RemovePii(System.ServiceModel.Diagnostics.DiagnosticStrings.HeadersPaths);
     }
 }
 public PlainXmlWriter(int maxSize)
 {
     this.currentAttributeText = string.Empty;
     this.navigator = new TraceXPathNavigator(maxSize);
 }
        private void BuildTrace(TraceEventType type, string msdnTraceCode, string description, TraceRecord trace, Exception exception, object source, out TraceXPathNavigator navigator)
        {
            PlainXmlWriter xml = new PlainXmlWriter(0xffff);

            navigator = xml.Navigator;
            this.BuildTrace(xml, type, msdnTraceCode, description, trace, exception, source);
            if (!this.TraceSource.ShouldLogPii)
            {
                navigator.RemovePii(System.ServiceModel.Diagnostics.DiagnosticStrings.HeadersPaths);
            }
        }
        void BuildTrace(TraceEventType type, string msdnTraceCode, string description, TraceRecord trace,
            Exception exception, object source, out TraceXPathNavigator navigator)
        {
            PlainXmlWriter xmlWriter = new PlainXmlWriter(LegacyDiagnosticTrace.MaxTraceSize);
            navigator = xmlWriter.Navigator;

            this.BuildTrace(xmlWriter, type, msdnTraceCode, description, trace, exception, source);

            if (!ShouldLogPii)
            {
                navigator.RemovePii(DiagnosticStrings.HeadersPaths);
            }
        }
 public PlainXmlWriter(int maxSize)
 {
     this.navigator = new TraceXPathNavigator(maxSize);
 }
 internal ElementNode(string name, string prefix, TraceXPathNavigator.ElementNode parent, string xmlns) : base(XPathNodeType.Element, parent)
 {
     this.childNodes = new List<TraceXPathNavigator.TraceNode>();
     this.attributes = new List<TraceXPathNavigator.AttributeNode>();
     this.name = name;
     this.prefix = prefix;
     this.xmlns = xmlns;
 }
 internal CommentNode(string text, TraceXPathNavigator.ElementNode parent) : base(XPathNodeType.Comment, parent)
 {
     this.nodeValue = text;
 }
Ejemplo n.º 13
0
 public PlainXmlWriter(int maxSize)
 {
     this.navigator = new TraceXPathNavigator(maxSize);
 }
Ejemplo n.º 14
0
 public PlainXmlWriter(int maxSize)
 {
     this.currentAttributeText = string.Empty;
     this.navigator            = new TraceXPathNavigator(maxSize);
 }
 protected TraceNode(XPathNodeType nodeType, TraceXPathNavigator.ElementNode parent)
 {
     this.nodeType = nodeType;
     this.parent = parent;
 }
 internal ProcessingInstructionNode(string name, string text, TraceXPathNavigator.ElementNode parent) : base(XPathNodeType.ProcessingInstruction, parent)
 {
     this.name = name;
     this.text = text;
 }
 internal void Add(TraceXPathNavigator.TraceNode node)
 {
     this.childNodes.Add(node);
 }