private LineOutColored?DotNetTest_OutputProcessor(EnumProcessOutputType type, string text) { if (text == null) { return(null); } EnumProcessOutputType processType = type; LineOutColored lineOutColored; ReadOnlySpan <char> textSpan = text; if (type == EnumProcessOutputType.ProcessErr) { return(LineOutColored.Error(text)); } // Find index of the actual message part: // First 2 columns are blank if (StringExtension.SpanSearcherContains(textSpan, "Failed", 2, 9)) { return(LineOutColored.LogicError(text)); } if (StringExtension.SpanSearcherContains(textSpan, "Failed!", 0, 9)) { return(LineOutColored.Error(text)); } if (StringExtension.SpanSearcherContains(textSpan, "Passed!", 0, 9)) { return(LineOutColored.Success(text)); } return(LineOutColored.Normal(text)); }
/// <summary> /// Writes the given text as Errored output to both BuildStage output and to the console real time. /// </summary> /// <param name="text"></param> protected void AOT_Error(string text) { StageOutput.Add(LineOutColored.Error(text)); if (ShouldLogToConsoleRealTime) { Console.WriteLine(text, Color.Red); } }
private static BlockingCollection <LineOutColored> GetOutputCollection( Process process, bool logTimestamp, [CanBeNull] Action <OutputType, string> logger, [CanBeNull] StreamWriter logFile, Func <string, string> outputFilter) { var output = new BlockingCollection <LineOutColored>(); string GetProcessedOutput(string data) => logTimestamp ? $"{DateTime.Now.ToLongTimeString()} {outputFilter.Invoke(data)}" : outputFilter.Invoke(data); // ******************************************************************************** process.OutputDataReceived += (_, e) => { if (e.Data == null) { return; } output.Add(LineOutColored.Normal(e.Data)); var processedOutput = GetProcessedOutput(e.Data); logFile?.WriteLine($"[STD] {processedOutput}"); logger?.Invoke(OutputType.Std, processedOutput); }; // ******************************************************************************** process.ErrorDataReceived += (_, e) => { if (e.Data == null) { return; } output.Add(LineOutColored.Error(e.Data)); var processedOutput = GetProcessedOutput(e.Data); logFile?.WriteLine($"[ERR] {processedOutput}"); logger?.Invoke(OutputType.Err, processedOutput); }; process.BeginOutputReadLine(); process.BeginErrorReadLine(); return(output); }
private LineOutColored?DotNetClean_OutputProcessor(EnumProcessOutputType type, string text) { if (text == null) { return(null); } EnumProcessOutputType processType = type; LineOutColored lineOutColored; ReadOnlySpan <char> textSpan = text; if (type == EnumProcessOutputType.ProcessErr) { return(LineOutColored.Error(text)); } return(LineOutColored.Normal(text)); }
/// <summary> /// Writes the given text as Errored output to both BuildStage output and to the console real time. /// </summary> /// <param name="text"></param> protected void AOT_Error(Exception exception) { string exceptionSeparator = "************************ [ Exception Encountered ] ************************"; int start = StageOutput.Count; StageOutput.Add(LineOutColored.Error(exceptionSeparator)); StageOutput.Add(LineOutColored.Error(exception.Message)); StageOutput.Add(LineOutColored.Error(exceptionSeparator)); StageOutput.Add(LineOutColored.NewLine()); StageOutput.Add(LineOutColored.Error(exception.ToString())); StageOutput.Add(LineOutColored.NewLine()); if (ShouldLogToConsoleRealTime) { Print_StageOutput(start); } }
private LineOutColored?DotNetPack_OutputProcessor(EnumProcessOutputType type, string text) { if (text == null) { return(null); } EnumProcessOutputType processType = type; LineOutColored lineOutColored; ReadOnlySpan <char> textSpan = text; if (type == EnumProcessOutputType.ProcessErr) { return(LineOutColored.Error(text)); } if (StringExtension.SpanSearcherContains(textSpan, "Successfully created package", 2, 32)) { return(LineOutColored.Success(text)); } return(LineOutColored.Normal(text)); }
private LineOutColored?DotNetNugetPush_OutputProcessor(EnumProcessOutputType type, string text) { if (text == null) { return(null); } EnumProcessOutputType processType = type; LineOutColored lineOutColored; ReadOnlySpan <char> textSpan = text; if (type == EnumProcessOutputType.ProcessErr) { return(LineOutColored.Error(text)); } if (StringExtension.SpanSearcherContains(textSpan, "warn :", 0, 7)) { return(LineOutColored.Warning(text)); } return(LineOutColored.Normal(text)); }
private LineOutColored?DotNetRestore_OutputProcessor(EnumProcessOutputType type, string text) { if (text == null) { return(null); } EnumProcessOutputType processType = type; LineOutColored lineOutColored; if (type == EnumProcessOutputType.ProcessErr) { return(LineOutColored.Error(text)); } if (text.StartsWith(" Restored")) { return(LineOutColored.Success(text)); } if (text.Contains("up-to-date:")) { return(LineOutColored.Success(text)); } return(LineOutColored.Normal(text)); }
private LineOutColored?DotNetBuild_OutputProcessor(EnumProcessOutputType type, string text) { if (text == null) { return(null); } EnumProcessOutputType processType = type; LineOutColored lineOutColored; ReadOnlySpan <char> textSpan = text; if (type == EnumProcessOutputType.ProcessErr) { return(LineOutColored.Error(text)); } // Find index of the actual message part: // The plus 17 is arbitrary as the src path,. still has a project path and source filename as well as line and column number entries int compileMsgStart = CISession.SourceDirectory.Length + 17; if (text.Length > compileMsgStart) { int index = text.IndexOf(": ", compileMsgStart); if (index > 0) { if (StringExtension.SpanSearcherContains(textSpan, "error", index + 2, index + 10)) { return(LineOutColored.LogicError(text)); } if (StringExtension.SpanSearcherContains(textSpan, "warning", index + 2, index + 10 + 50)) { return(LineOutColored.Warning(text)); } } } return(LineOutColored.Normal(text)); }