Exemplo n.º 1
0
        /// <inheritdoc />
        protected override void LogImpl(LogSeverity severity, string message, ExceptionData exceptionData)
        {
            switch (severity)
            {
            case LogSeverity.Error:
                testListener.WriteLine(message, FacadeCategory.Error);
                break;

            case LogSeverity.Warning:
                testListener.WriteLine(message, FacadeCategory.Warning);
                break;

            case LogSeverity.Important:
            case LogSeverity.Info:
                testListener.WriteLine(message, FacadeCategory.Info);
                break;

            case LogSeverity.Debug:
                testListener.WriteLine(message, FacadeCategory.Debug);
                break;
            }

            if (exceptionData != null)
            {
                testListener.WriteLine(exceptionData.ToString(), FacadeCategory.Error);
            }
        }
        protected override void LogImpl(LogSeverity severity, string message, ExceptionData exceptionData)
        {
            var warning = exceptionData == null
                   ? message
                   : string.Concat(message, "\n", exceptionData.ToString());

            switch (severity)
            {
                case LogSeverity.Info:
                    _messageLogger.SendMessage(TestMessageLevel.Informational, warning);
                    break;
                case LogSeverity.Warning:
                    _messageLogger.SendMessage(TestMessageLevel.Warning, warning);
                    break;
                case LogSeverity.Debug:
                    _messageLogger.SendMessage(TestMessageLevel.Informational, warning);
                    break;
                case LogSeverity.Important:
                    _messageLogger.SendMessage(TestMessageLevel.Informational, warning);
                    break;
                case LogSeverity.Error:
                    _messageLogger.SendMessage(TestMessageLevel.Error, warning);
                    break;
            }
        }
Exemplo n.º 3
0
        public void ToStringBareBones()
        {
            ExceptionData data = new ExceptionData("type", "message", "stacktrace", ExceptionData.NoProperties, null);

            Assert.AreEqual("type: message\nstacktrace",
                            data.ToString());
        }
Exemplo n.º 4
0
        /// <inheritdoc />
        protected override void LogImpl(LogSeverity severity, string message, ExceptionData exceptionData)
        {
            switch (severity)
            {
                case LogSeverity.Error:
                    testListener.WriteLine(message, FacadeCategory.Error);
                    break;

                case LogSeverity.Warning:
                    testListener.WriteLine(message, FacadeCategory.Warning);
                    break;

                case LogSeverity.Important:
                case LogSeverity.Info:
                    testListener.WriteLine(message, FacadeCategory.Info);
                    break;

                case LogSeverity.Debug:
                    testListener.WriteLine(message, FacadeCategory.Debug);
                    break;
            }

            if (exceptionData != null)
                testListener.WriteLine(exceptionData.ToString(), FacadeCategory.Error);
        }
Exemplo n.º 5
0
        protected override void LogImpl(LogSeverity severity, string message, ExceptionData exceptionData)
        {
            if (severity < MinLogSeverity || LogMessage == null)
                return;

            Color color = Color.Black;
            switch (severity)
            {
                case LogSeverity.Error:
                    color = Color.Red;
                    break;

                case LogSeverity.Warning:
                    color = Color.Gold;
                    break;

                case LogSeverity.Important:
                    color = Color.Black;
                    break;

                case LogSeverity.Info:
                    color = Color.Gray;
                    break;

                case LogSeverity.Debug:
                    color = Color.DarkGray;
                    break;
            }

            LogMessage(this, new RuntimeLogEventArgs(message, color));

            if (exceptionData != null)
                LogMessage(this, new RuntimeLogEventArgs(exceptionData.ToString(), color));
        }
        protected override void LogImpl(LogSeverity severity, string message, ExceptionData exceptionData)
        {
            var warning = exceptionData == null
                   ? message
                   : string.Concat(message, "\n", exceptionData.ToString());

            switch (severity)
            {
            case LogSeverity.Info:
                _messageLogger.SendMessage(TestMessageLevel.Informational, warning);
                break;

            case LogSeverity.Warning:
                _messageLogger.SendMessage(TestMessageLevel.Warning, warning);
                break;

            case LogSeverity.Debug:
                _messageLogger.SendMessage(TestMessageLevel.Informational, warning);
                break;

            case LogSeverity.Important:
                _messageLogger.SendMessage(TestMessageLevel.Informational, warning);
                break;

            case LogSeverity.Error:
                _messageLogger.SendMessage(TestMessageLevel.Error, warning);
                break;
            }
        }
Exemplo n.º 7
0
        protected override void LogImpl(LogSeverity severity, string message, ExceptionData exceptionData)
        {
            TestOutcome outcome;

            if (severity == LogSeverity.Warning)
            {
                outcome = TestOutcome.Warning;
            }
            else if (severity == LogSeverity.Error)
            {
                outcome = TestOutcome.Error;
            }
            else
            {
                return;
            }

            if (exceptionData != null)
            {
                message = string.Concat(message, "\n", exceptionData.ToString());
            }

            TestRunTextResultMessage resultMessage = new TestRunTextResultMessage(runContext.RunConfig.TestRun.Id, message);

            resultMessage.Outcome = outcome;

            runContext.ResultSink.AddResult(resultMessage);
        }
Exemplo n.º 8
0
 private void DistributerOnExceptionThrown(ExceptionData exceptionData)
 {
     if (!(exceptionData.ThrownException is SocketException))
     {
         return;
     }
     this.InvokeIfRequired(() =>
     {
         PopupMessageForm.ShowMessage(exceptionData.ToString(), Color.Red, this, 5, withSiren: true);
     });
 }
Exemplo n.º 9
0
        protected override void LogImpl(LogSeverity severity, string message, ExceptionData exceptionData)
        {
            if (severity >= LogSeverity.Warning)
            {
                string warning = exceptionData == null
                    ? message
                    : string.Concat(message, "\n", exceptionData.ToString());

                warningHandler.Write(this, new WarningEventArgs(warning));
            }
        }
Exemplo n.º 10
0
        protected override void LogImpl(LogSeverity severity, string message, ExceptionData exceptionData)
        {
            if (severity >= LogSeverity.Warning)
            {
                string warning = exceptionData == null
                    ? message
                    : string.Concat(message, "\n", exceptionData.ToString());

                warningHandler.Write(this, new WarningEventArgs(warning));
            }
        }
Exemplo n.º 11
0
        /// <inheritdoc />
        protected override void LogImpl(LogSeverity severity, string message, ExceptionData exceptionData)
        {
            lock (console.SyncRoot)
            {
                bool oldFooterVisible = console.FooterVisible;
                try
                {
                    console.FooterVisible = false;

                    if (!console.IsRedirected)
                    {
                        switch (severity)
                        {
                        case LogSeverity.Error:
                            console.ForegroundColor = ConsoleColor.Red;
                            break;

                        case LogSeverity.Warning:
                            console.ForegroundColor = ConsoleColor.Yellow;
                            break;

                        case LogSeverity.Important:
                            console.ForegroundColor = ConsoleColor.White;
                            break;

                        case LogSeverity.Info:
                            console.ForegroundColor = ConsoleColor.Gray;
                            break;

                        case LogSeverity.Debug:
                            console.ForegroundColor = ConsoleColor.DarkGray;
                            break;
                        }
                    }

                    console.WriteLine(message);

                    if (exceptionData != null)
                    {
                        console.WriteLine(Indent(exceptionData.ToString()));
                    }

                    if (!console.IsRedirected)
                    {
                        console.ResetColor();
                    }
                }
                finally
                {
                    console.FooterVisible = oldFooterVisible;
                }
            }
        }
Exemplo n.º 12
0
        /// <inheritdoc />
        protected override void LogImpl(LogSeverity severity, string message, ExceptionData exceptionData)
        {
            if (severity < LogSeverity.Info)
                return;

            StringBuilder output = new StringBuilder();
            output.AppendLine(message);
            if (exceptionData != null)
            {
                output.Append("  ");
                output.AppendLine(exceptionData.ToString());
            }

            IVsOutputWindowPane outputWindowPane = GetOutputWindowPane();
            outputWindowPane.OutputStringThreadSafe(output.ToString());
        }
Exemplo n.º 13
0
        public void ToStringEverything(bool useStandardFormatting)
        {
            ExceptionData innerData = new ExceptionData("type", "message", "stacktrace", ExceptionData.NoProperties, null);
            ExceptionData outerData = new ExceptionData("type", "message", "stacktrace",
                                                        new PropertySet()
            {
                { "Prop1", "Value1" },
                { "Prop2", "Value2" }
            }, innerData);

            Assert.AreEqual("type: message ---> type: message\n"
                            + "stacktrace\n   --- End of inner exception stack trace ---\n"
                            + (useStandardFormatting ? "" : "Prop1: Value1\nProp2: Value2\n")
                            + "stacktrace",
                            outerData.ToString(useStandardFormatting));
        }
Exemplo n.º 14
0
        protected override void LogImpl(LogSeverity severity, string message, ExceptionData exceptionData)
        {
            TestOutcome outcome;
            if (severity == LogSeverity.Warning)
                outcome = TestOutcome.Warning;
            else if (severity == LogSeverity.Error)
                outcome = TestOutcome.Error;
            else
                return;

            if (exceptionData != null)
                message = string.Concat(message, "\n", exceptionData.ToString());

            TestRunTextResultMessage resultMessage = new TestRunTextResultMessage(runContext.RunConfig.TestRun.Id, message);
            resultMessage.Outcome = outcome;

            runContext.ResultSink.AddResult(resultMessage);
        }
Exemplo n.º 15
0
            public void RecordLogEntry(LogSeverity severity, string message, ExceptionData exceptionData)
            {
                reportBox.Write(report =>
                {
                    if (states == null)
                    {
                        return; // ignore the message if the listener was disposed before it could be written
                    }
                    report.AddLogEntry(new LogEntry()
                    {
                        Severity = severity,
                        Message  = message,
                        Details  = exceptionData != null ? exceptionData.ToString() : null
                    });

                    eventDispatcher.NotifyLogEntrySubmitted(new LogEntrySubmittedEventArgs(severity, message, exceptionData));
                });
            }
Exemplo n.º 16
0
        /// <summary>
        /// Logs a message.
        /// </summary>
        /// <param name="severity">The log message severity.</param>
        /// <param name="message">The message to log.</param>
        /// <param name="exceptionData">The exception to log (it can be null).</param>
        protected override void LogImpl(LogSeverity severity, string message, ExceptionData exceptionData)
        {
            // The PowerShell logging methods may throw InvalidOperationException
            // or NotImplementedException if the PowerShell host is not connected
            // or does not support the requested service.  So we eat those exceptions.
            cmdlet.PostMessage(delegate
            {
                try
                {
                    if (exceptionData != null)
                    {
                        message = string.Concat(message, "\n", exceptionData.ToString());
                    }

                    switch (severity)
                    {
                    case LogSeverity.Error:
                        cmdlet.WriteError(new ErrorRecord(new Exception(message), "Error", ErrorCategory.NotSpecified, "Gallio"));
                        break;

                    case LogSeverity.Warning:
                        cmdlet.WriteWarning(message);
                        break;

                    case LogSeverity.Important:
                    case LogSeverity.Info:
                        cmdlet.WriteVerbose(message);
                        break;

                    case LogSeverity.Debug:
                        cmdlet.WriteDebug(message);
                        break;
                    }
                }
                catch (NotImplementedException)
                {
                }
                catch (InvalidOperationException)
                {
                }
            });
        }
Exemplo n.º 17
0
        /// <inheritdoc />
        protected override void LogImpl(LogSeverity severity, string message, ExceptionData exceptionData)
        {
            if (severity < LogSeverity.Info)
            {
                return;
            }

            StringBuilder output = new StringBuilder();

            output.AppendLine(message);
            if (exceptionData != null)
            {
                output.Append("  ");
                output.AppendLine(exceptionData.ToString());
            }

            IVsOutputWindowPane outputWindowPane = GetOutputWindowPane();

            outputWindowPane.OutputStringThreadSafe(output.ToString());
        }
Exemplo n.º 18
0
        /// <summary>
        /// Logs a message.
        /// </summary>
        /// <param name="severity">The log message severity.</param>
        /// <param name="message">The message to log.</param>
        /// <param name="exceptionData">The exception to log (it can be null).</param>
        protected override void LogImpl(LogSeverity severity, string message, ExceptionData exceptionData)
        {
            // The PowerShell logging methods may throw InvalidOperationException
            // or NotImplementedException if the PowerShell host is not connected
            // or does not support the requested service.  So we eat those exceptions.
            cmdlet.PostMessage(delegate
            {
                try
                {
                    if (exceptionData != null)
                        message = string.Concat(message, "\n", exceptionData.ToString());

                    switch (severity)
                    {
                        case LogSeverity.Error:
                            cmdlet.WriteError(new ErrorRecord(new Exception(message), "Error", ErrorCategory.NotSpecified, "Gallio"));
                            break;

                        case LogSeverity.Warning:
                            cmdlet.WriteWarning(message);
                            break;

                        case LogSeverity.Important:
                        case LogSeverity.Info:
                            cmdlet.WriteVerbose(message);
                            break;

                        case LogSeverity.Debug:
                            cmdlet.WriteDebug(message);
                            break;
                    }
                }
                catch (NotImplementedException)
                {
                }
                catch (InvalidOperationException)
                {
                }
            });
        }
Exemplo n.º 19
0
        protected override void LogImpl(LogSeverity severity, string message, ExceptionData exceptionData)
        {
            if (severity < MinLogSeverity || LogMessage == null)
            {
                return;
            }

            Color color = Color.Black;

            switch (severity)
            {
            case LogSeverity.Error:
                color = Color.Red;
                break;

            case LogSeverity.Warning:
                color = Color.Gold;
                break;

            case LogSeverity.Important:
                color = Color.Black;
                break;

            case LogSeverity.Info:
                color = Color.Gray;
                break;

            case LogSeverity.Debug:
                color = Color.DarkGray;
                break;
            }

            LogMessage(this, new RuntimeLogEventArgs(message, color));

            if (exceptionData != null)
            {
                LogMessage(this, new RuntimeLogEventArgs(exceptionData.ToString(), color));
            }
        }
Exemplo n.º 20
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("{0} | ", LogTime.ToString("MM/dd/yyyy hh:mm:ss.ffff tt"));
            //sb.AppendLine();

            if (CallerIp != null && CallerPort > 0)
            {
                sb.AppendFormat("Caller Ip: {0} | ", CallerIp);
                sb.AppendFormat("Caller Port: {0} | ", CallerPort);
                //sb.AppendLine();
            }

            sb.AppendFormat("Operation: {0} | ", OperationName ?? String.Empty);
            //sb.AppendLine();
            sb.AppendFormat("Log type: {0} | ", LogType);
            //sb.AppendLine();


            if (InputsData != null)
            {
                string strInputs = InputsData.ToString();
                if (!string.IsNullOrEmpty(strInputs))
                {
                    sb.AppendFormat("Inputs: {0} | ", strInputs);
                    //sb.AppendLine();
                }
            }

            if (OutputsData != null)
            {
                string strOutputs = OutputsData.ToString();
                if (!string.IsNullOrEmpty(strOutputs))
                {
                    sb.AppendFormat("Outputs: {0} | ", strOutputs);
                    //sb.AppendLine();
                }
            }

            if (ReturnValueData != null)
            {
                string strReturnValue = ReturnValueData.ToString();
                if (!string.IsNullOrEmpty(strReturnValue))
                {
                    sb.AppendFormat("Return value: {0} | ", strReturnValue);
                    //sb.AppendLine();
                }
            }

            if (ExceptionData != null)
            {
                string strException = ExceptionData.ToString();
                if (!string.IsNullOrEmpty(strException))
                {
                    sb.AppendFormat("Exception: {0} | ", strException);
                    //sb.AppendLine();
                }
            }

            if (InformationData != null)
            {
                string strInformation = InformationData.ToString();
                if (!string.IsNullOrEmpty(strInformation))
                {
                    sb.AppendFormat("Information: {0} | ", strInformation);
                    //sb.AppendLine();
                }
            }
            sb.AppendLine();
            return(sb.ToString());
        }
Exemplo n.º 21
0
 public void ToStringBareBones()
 {
     ExceptionData data = new ExceptionData("type", "message", "stacktrace", ExceptionData.NoProperties, null);
     Assert.AreEqual("type: message\nstacktrace",
         data.ToString());
 }
Exemplo n.º 22
0
 public void ToStringEverything(bool useStandardFormatting)
 {
     ExceptionData innerData = new ExceptionData("type", "message", "stacktrace", ExceptionData.NoProperties, null);
     ExceptionData outerData = new ExceptionData("type", "message", "stacktrace", 
         new PropertySet() {
             { "Prop1", "Value1" },
             { "Prop2", "Value2" }
         }, innerData);
     Assert.AreEqual("type: message ---> type: message\n"
         + "stacktrace\n   --- End of inner exception stack trace ---\n"
         + (useStandardFormatting ? "" : "Prop1: Value1\nProp2: Value2\n")
         + "stacktrace",
         outerData.ToString(useStandardFormatting));
 }
Exemplo n.º 23
0
            public void RecordLogEntry(LogSeverity severity, string message, ExceptionData exceptionData)
            {
                reportBox.Write(report =>
                {
                    if (states == null)
                        return; // ignore the message if the listener was disposed before it could be written

                    report.AddLogEntry(new LogEntry()
                    {
                        Severity = severity,
                        Message = message,
                        Details = exceptionData != null ? exceptionData.ToString() : null
                    });

                    eventDispatcher.NotifyLogEntrySubmitted(new LogEntrySubmittedEventArgs(severity, message, exceptionData));
                });
            }
Exemplo n.º 24
0
        /// <inheritdoc />
        protected override void LogImpl(LogSeverity severity, string message, ExceptionData exceptionData)
        {
            lock (console.SyncRoot)
            {
                bool oldFooterVisible = console.FooterVisible;
                try
                {
                    console.FooterVisible = false;

                    if (!console.IsRedirected)
                    {
                        switch (severity)
                        {
                            case LogSeverity.Error:
                                console.ForegroundColor = ConsoleColor.Red;
                                break;

                            case LogSeverity.Warning:
                                console.ForegroundColor = ConsoleColor.Yellow;
                                break;

                            case LogSeverity.Important:
                                console.ForegroundColor = ConsoleColor.White;
                                break;

                            case LogSeverity.Info:
                                console.ForegroundColor = ConsoleColor.Gray;
                                break;

                            case LogSeverity.Debug:
                                console.ForegroundColor = ConsoleColor.DarkGray;
                                break;
                        }
                    }

                    console.WriteLine(message);

                    if (exceptionData != null)
                        console.WriteLine(Indent(exceptionData.ToString()));

                    if (!console.IsRedirected)
                    {
                        console.ResetColor();
                    }
                }
                finally
                {
                    console.FooterVisible = oldFooterVisible;
                }
            }
        }