Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 1e83ded

Browse files
committed
Add some more logging
1 parent dfd07a3 commit 1e83ded

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/GitHub.Api/Tasks/ProcessTask.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ interface IProcessTask<TData, T> : ITask<TData, T>, IProcess
5454

5555
class ProcessWrapper
5656
{
57+
private readonly string taskName;
5758
private readonly IOutputProcessor outputProcessor;
5859
private readonly Action onStart;
5960
private readonly Action onEnd;
@@ -67,10 +68,11 @@ class ProcessWrapper
6768
private ILogging logger;
6869
protected ILogging Logger { get { return logger = logger ?? LogHelper.GetLogger(GetType()); } }
6970

70-
public ProcessWrapper(Process process, IOutputProcessor outputProcessor,
71+
public ProcessWrapper(string taskName, Process process, IOutputProcessor outputProcessor,
7172
Action onStart, Action onEnd, Action<Exception, string> onError,
7273
CancellationToken token)
7374
{
75+
this.taskName = taskName;
7476
this.outputProcessor = outputProcessor;
7577
this.onStart = onStart;
7678
this.onEnd = onEnd;
@@ -102,8 +104,7 @@ public void Run()
102104

103105
try
104106
{
105-
if (!Process.StartInfo.Arguments.StartsWith("credential-"))
106-
Logger.Trace($"Running '{Process.StartInfo.FileName.ToNPath().FileName} {Process.StartInfo.Arguments}'");
107+
Logger.Trace($"Running '{Process.StartInfo.FileName.ToNPath().FileName} {taskName}'");
107108

108109
Process.Start();
109110

@@ -158,6 +159,10 @@ public void Run()
158159
var errorCode = ex.NativeErrorCode;
159160

160161
StringBuilder sb = new StringBuilder();
162+
if (Process.StartInfo.Arguments.Contains("-credential"))
163+
sb.AppendLine($"'{Process.StartInfo.FileName} {taskName}'");
164+
else
165+
sb.AppendLine($"'{Process.StartInfo.FileName} {Process.StartInfo.Arguments}'");
161166
if (errorCode == 2)
162167
sb.AppendLine("The system cannot find the file specified.");
163168
foreach (string env in Process.StartInfo.EnvironmentVariables.Keys)
@@ -240,6 +245,7 @@ public virtual void Configure(ProcessStartInfo psi)
240245
Guard.NotNull(this, outputProcessor, nameof(outputProcessor));
241246
Process = new Process { StartInfo = psi, EnableRaisingEvents = true };
242247
ProcessName = psi.FileName;
248+
Name = ProcessArguments;
243249
}
244250

245251
public virtual void Configure(ProcessStartInfo psi, IOutputProcessor<T> processor)
@@ -251,6 +257,7 @@ public virtual void Configure(ProcessStartInfo psi, IOutputProcessor<T> processo
251257

252258
Process = new Process { StartInfo = psi, EnableRaisingEvents = true };
253259
ProcessName = psi.FileName;
260+
Name = ProcessArguments;
254261
}
255262

256263
public void Configure(Process existingProcess)
@@ -263,6 +270,7 @@ public void Configure(Process existingProcess)
263270

264271
Process = existingProcess;
265272
ProcessName = existingProcess.StartInfo.FileName;
273+
Name = ProcessArguments;
266274
}
267275

268276
protected override void RaiseOnStart()
@@ -285,7 +293,7 @@ protected override T RunWithReturn(bool success)
285293
{
286294
var result = base.RunWithReturn(success);
287295

288-
wrapper = new ProcessWrapper(Process, outputProcessor,
296+
wrapper = new ProcessWrapper(Name, Process, outputProcessor,
289297
RaiseOnStart,
290298
() =>
291299
{
@@ -421,7 +429,7 @@ protected override List<T> RunWithReturn(bool success)
421429
{
422430
var result = base.RunWithReturn(success);
423431

424-
wrapper = new ProcessWrapper(Process, outputProcessor,
432+
wrapper = new ProcessWrapper(Name, Process, outputProcessor,
425433
RaiseOnStart,
426434
() =>
427435
{

0 commit comments

Comments
 (0)