mirror of
https://github.com/actions/runner.git
synced 2025-12-12 05:37:01 +00:00
Made worker logs available to stdout (#2307)
* Made worker logs available to stdout * Log Worker Standard out line by line Co-authored-by: Ferenc Hammerl <31069338+fhammerl@users.noreply.github.com>
This commit is contained in:
@@ -18,7 +18,7 @@ namespace GitHub.Runner.Common
|
|||||||
string ReadSecret();
|
string ReadSecret();
|
||||||
void Write(string message, ConsoleColor? colorCode = null);
|
void Write(string message, ConsoleColor? colorCode = null);
|
||||||
void WriteLine();
|
void WriteLine();
|
||||||
void WriteLine(string line, ConsoleColor? colorCode = null);
|
void WriteLine(string line, ConsoleColor? colorCode = null, bool skipTracing = false);
|
||||||
void WriteError(Exception ex);
|
void WriteError(Exception ex);
|
||||||
void WriteError(string line);
|
void WriteError(string line);
|
||||||
void WriteSection(string message);
|
void WriteSection(string message);
|
||||||
@@ -116,9 +116,12 @@ namespace GitHub.Runner.Common
|
|||||||
|
|
||||||
// Do not add a format string overload. Terminal messages are user facing and therefore
|
// Do not add a format string overload. Terminal messages are user facing and therefore
|
||||||
// should be localized. Use the Loc method in the StringUtil class.
|
// should be localized. Use the Loc method in the StringUtil class.
|
||||||
public void WriteLine(string line, ConsoleColor? colorCode = null)
|
public void WriteLine(string line, ConsoleColor? colorCode = null, bool skipTracing = false)
|
||||||
|
{
|
||||||
|
if (!skipTracing)
|
||||||
{
|
{
|
||||||
Trace.Info($"WRITE LINE: {line}");
|
Trace.Info($"WRITE LINE: {line}");
|
||||||
|
}
|
||||||
if (!Silent)
|
if (!Silent)
|
||||||
{
|
{
|
||||||
if (colorCode != null)
|
if (colorCode != null)
|
||||||
|
|||||||
@@ -400,6 +400,7 @@ namespace GitHub.Runner.Listener
|
|||||||
Task<int> workerProcessTask = null;
|
Task<int> workerProcessTask = null;
|
||||||
object _outputLock = new();
|
object _outputLock = new();
|
||||||
List<string> workerOutput = new();
|
List<string> workerOutput = new();
|
||||||
|
bool printToStdout = StringUtil.ConvertToBoolean(Environment.GetEnvironmentVariable(Constants.Variables.Agent.PrintLogToStdout));
|
||||||
using (var processChannel = HostContext.CreateService<IProcessChannel>())
|
using (var processChannel = HostContext.CreateService<IProcessChannel>())
|
||||||
using (var processInvoker = HostContext.CreateService<IProcessInvoker>())
|
using (var processInvoker = HostContext.CreateService<IProcessInvoker>())
|
||||||
{
|
{
|
||||||
@@ -420,9 +421,17 @@ namespace GitHub.Runner.Listener
|
|||||||
if (!string.IsNullOrEmpty(stdout.Data))
|
if (!string.IsNullOrEmpty(stdout.Data))
|
||||||
{
|
{
|
||||||
lock (_outputLock)
|
lock (_outputLock)
|
||||||
|
{
|
||||||
|
if (!stdout.Data.StartsWith("[WORKER"))
|
||||||
{
|
{
|
||||||
workerOutput.Add(stdout.Data);
|
workerOutput.Add(stdout.Data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (printToStdout)
|
||||||
|
{
|
||||||
|
term.WriteLine(stdout.Data, skipTracing: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user