mirror of
https://github.com/github/codeql.git
synced 2026-04-27 09:45:15 +02:00
Add managed thread ID to extractor log messages
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Semmle.Util
|
||||
@@ -7,9 +8,11 @@ namespace Semmle.Util
|
||||
{
|
||||
/// <summary>
|
||||
/// Runs this process, and returns the exit code, as well as the contents
|
||||
/// of stdout in <paramref name="stdout"/>.
|
||||
/// of stdout in <paramref name="stdout"/>. If <paramref name="printToConsole"/>
|
||||
/// is true, then stdout is printed to the console and each line is prefixed
|
||||
/// with the thread id.
|
||||
/// </summary>
|
||||
public static int ReadOutput(this ProcessStartInfo pi, out IList<string> stdout)
|
||||
public static int ReadOutput(this ProcessStartInfo pi, out IList<string> stdout, bool printToConsole)
|
||||
{
|
||||
stdout = new List<string>();
|
||||
using var process = Process.Start(pi);
|
||||
@@ -27,6 +30,10 @@ namespace Semmle.Util
|
||||
s = process.StandardOutput.ReadLine();
|
||||
if (s is not null)
|
||||
{
|
||||
if (printToConsole)
|
||||
{
|
||||
Console.WriteLine($"[{Environment.CurrentManagedThreadId:D3}] {s}");
|
||||
}
|
||||
stdout.Add(s);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user