/// <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; } }
public void ToStringBareBones() { ExceptionData data = new ExceptionData("type", "message", "stacktrace", ExceptionData.NoProperties, null); Assert.AreEqual("type: message\nstacktrace", data.ToString()); }
/// <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) { 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) { 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); }
private void DistributerOnExceptionThrown(ExceptionData exceptionData) { if (!(exceptionData.ThrownException is SocketException)) { return; } this.InvokeIfRequired(() => { PopupMessageForm.ShowMessage(exceptionData.ToString(), Color.Red, this, 5, withSiren: true); }); }
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)); } }
/// <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; } } }
/// <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()); }
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)); }
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); }
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)); }); }
/// <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) { } }); }
/// <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()); }
/// <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) { } }); }
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)); } }
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()); }
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)); }); }
/// <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; } } }