public OutputWindowTraceListener(TraceStreamOptions options)
        {
            this.options = options;
            var outputWindow = Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;

            Guid debugPaneGuid = VSConstants.OutputWindowPaneGuid.DebugPane_guid;
            var result = outputWindow.GetPane(ref debugPaneGuid, out debugPane);
            if (result != VSConstants.S_OK)
            {
                throw new Exception("Unable to get an instance of the debug window pane");
            }
        }
Exemplo n.º 2
0
        private XElement ComposeXmlMessage(TraceMessageSourceEntry message, TraceStreamOptions options)
        {
            XElement element = new XElement(XName.Get(Names.TraceEntry));

            var symbolExpression = message.Expression;

            if (symbolExpression.IsValidValue)
            {
                var symbolElement = new XElement(XName.Get(Names.LocalVariableEntry));
                symbolElement.SetAttributeValue(XName.Get(Names.LocalVariableEntryAttributeName), symbolExpression.Name);
                symbolElement.SetAttributeValue(XName.Get(Names.LocalVariableEntryAttributeValue), symbolExpression.Value);
                element.Add(symbolElement);
            }

            if (options.IncludeDateTime)
            {
                element.Add(new XElement(XName.Get(Names.TimeStamp)), DateTime.Now.ToString());
            }

            if (options.IncludeColumnNumber)
            {
                var colNumber = new XElement(XName.Get(Names.FileColumn), message.Breakpoint.FileColumn);
                element.Add(colNumber);
            }
            if (options.IncludeFileName)
            {
                var fileName = new XElement(XName.Get(Names.FileName), message.Breakpoint.File);
                element.Add(fileName);
            }
            if (options.IncludeFunctionName)
            {
                var functionName = new XElement(XName.Get(Names.FunctionName), message.Breakpoint.FunctionName);
                element.Add(functionName);
            }
            if (options.IncludeLineNumber)
            {
                var lineNumber = new XElement(XName.Get(Names.FileLine), message.Breakpoint.FileLine);
                element.Add(lineNumber);
            }
            if (options.IncludeLocalVariables)
            {
                var localElement = new XElement(XName.Get(Names.Locals));
                element.Add(localElement);
                foreach (Expression variable in message.StackFrame.Locals)
                {
                    var localVariable = new XElement(XName.Get(Names.LocalVariableEntry));
                    localVariable.SetAttributeValue(XName.Get(Names.LocalVariableEntryAttributeName), variable.Name);
                    localVariable.SetAttributeValue(XName.Get(Names.LocalVariableEntryAttributeValue), variable.Value);
                    localElement.Add(localVariable);
                }
            }
            return(element);
        }
        public FileStreamTraceListener(string fileName, TraceStreamOptions options)
        {
            if (string.IsNullOrEmpty(fileName))
                throw new ArgumentException("Invalid file name", "fileName");
            if (Path.GetInvalidFileNameChars().Any() || Path.GetInvalidPathChars().Any())
                throw new ArgumentException("Invalid characters found in path", "fileName");
            if (!Directory.Exists(Path.GetDirectoryName(fileName)))
                throw new DirectoryNotFoundException(string.Format("Unable to create a file stream for the file {0}", fileName));

            writer = new StreamWriter(fileName);
            this.options = options;
        }
        public OutputWindowTraceListener(TraceStreamOptions options)
        {
            this.options = options;
            var outputWindow = Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;

            Guid debugPaneGuid = VSConstants.OutputWindowPaneGuid.DebugPane_guid;
            var  result        = outputWindow.GetPane(ref debugPaneGuid, out debugPane);

            if (result != VSConstants.S_OK)
            {
                throw new Exception("Unable to get an instance of the debug window pane");
            }
        }
        public FileStreamTraceListener(string fileName, TraceStreamOptions options)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentException("Invalid file name", "fileName");
            }
            if (Path.GetInvalidFileNameChars().Any() || Path.GetInvalidPathChars().Any())
            {
                throw new ArgumentException("Invalid characters found in path", "fileName");
            }
            if (!Directory.Exists(Path.GetDirectoryName(fileName)))
            {
                throw new DirectoryNotFoundException(string.Format("Unable to create a file stream for the file {0}", fileName));
            }

            writer       = new StreamWriter(fileName);
            this.options = options;
        }
Exemplo n.º 6
0
        private XElement ComposeXmlMessage(TraceMessageSourceEntry message, TraceStreamOptions options)
        {
            XElement element = new XElement(XName.Get(Names.TraceEntry));

            var symbolExpression = message.Expression;

            if (symbolExpression.IsValidValue)
            {
                var symbolElement = new XElement(XName.Get(Names.LocalVariableEntry));
                symbolElement.SetAttributeValue(XName.Get(Names.LocalVariableEntryAttributeName), symbolExpression.Name);
                symbolElement.SetAttributeValue(XName.Get(Names.LocalVariableEntryAttributeValue), symbolExpression.Value);
                element.Add(symbolElement);
            }

            if (options.IncludeDateTime)
            {
                element.Add(new XElement(XName.Get(Names.TimeStamp)), DateTime.Now.ToString());
            }

            if (options.IncludeColumnNumber)
            {
                var colNumber = new XElement(XName.Get(Names.FileColumn), message.Breakpoint.FileColumn);
                element.Add(colNumber);
            }
            if (options.IncludeFileName)
            {
                var fileName = new XElement(XName.Get(Names.FileName), message.Breakpoint.File);
                element.Add(fileName);
            }
            if (options.IncludeFunctionName)
            {
                var functionName = new XElement(XName.Get(Names.FunctionName), message.Breakpoint.FunctionName);
                element.Add(functionName);
            }
            if (options.IncludeLineNumber)
            {
                var lineNumber = new XElement(XName.Get(Names.FileLine), message.Breakpoint.FileLine);
                element.Add(lineNumber);
            }
            if (options.IncludeLocalVariables)
            {
                var localElement = new XElement(XName.Get(Names.Locals));
                element.Add(localElement);
                foreach (Expression variable in message.StackFrame.Locals)
                {
                    var localVariable = new XElement(XName.Get(Names.LocalVariableEntry));
                    localVariable.SetAttributeValue(XName.Get(Names.LocalVariableEntryAttributeName), variable.Name);
                    localVariable.SetAttributeValue(XName.Get(Names.LocalVariableEntryAttributeValue), variable.Value);
                    localElement.Add(localVariable);
                }
            }
            return element;
        }