forked from actions/runner
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Composite Code Cleanup (actions#1232)
* composite polish * Cleanup Condition Handling * Refactor ConditionTraceWriter * pr feedback * cleanup
- Loading branch information
Showing
5 changed files
with
184 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
using System.Text; | ||
using GitHub.DistributedTask.Pipelines; | ||
using GitHub.Runner.Common; | ||
using GitHub.Runner.Sdk; | ||
using ObjectTemplating = GitHub.DistributedTask.ObjectTemplating; | ||
|
||
namespace GitHub.Runner.Worker | ||
{ | ||
public sealed class ConditionTraceWriter : ObjectTemplating::ITraceWriter | ||
{ | ||
private readonly IExecutionContext _executionContext; | ||
private readonly Tracing _trace; | ||
private readonly StringBuilder _traceBuilder = new StringBuilder(); | ||
|
||
public string Trace => _traceBuilder.ToString(); | ||
|
||
public ConditionTraceWriter(Tracing trace, IExecutionContext executionContext) | ||
{ | ||
ArgUtil.NotNull(trace, nameof(trace)); | ||
_trace = trace; | ||
_executionContext = executionContext; | ||
} | ||
|
||
public void Error(string format, params Object[] args) | ||
{ | ||
var message = StringUtil.Format(format, args); | ||
_trace.Error(message); | ||
_executionContext?.Debug(message); | ||
} | ||
|
||
public void Info(string format, params Object[] args) | ||
{ | ||
var message = StringUtil.Format(format, args); | ||
_trace.Info(message); | ||
_executionContext?.Debug(message); | ||
_traceBuilder.AppendLine(message); | ||
} | ||
|
||
public void Verbose(string format, params Object[] args) | ||
{ | ||
var message = StringUtil.Format(format, args); | ||
_trace.Verbose(message); | ||
_executionContext?.Debug(message); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters