Skip to content

Commit 2159190

Browse files
authored
Unify main and app output logs to improve the UX of failure investigation (#1348)
* unify adb and main console log output on Android * unify main and appOutputLog for iOS devices * Unify logs for MacCatalyst
1 parent 073824d commit 2159190

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

src/Microsoft.DotNet.XHarness.Android/AdbRunner.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ public bool TryDumpAdbLog(string outputFilePath, string filterSpec = "")
154154
Directory.CreateDirectory(Path.GetDirectoryName(outputFilePath) ?? throw new ArgumentNullException(nameof(outputFilePath)));
155155
File.WriteAllText(outputFilePath, result.StandardOutput);
156156
_log.LogInformation($"Wrote current ADB log to {outputFilePath}");
157+
// The adb log is not directly accessible.
158+
// Hence, we duplicate the log to the main console log to simplify the UX of failure investigation.
159+
_log.LogInformation($"ADB log output:{Environment.NewLine}{result.StandardOutput}");
157160
return true;
158161
}
159162
}

src/Microsoft.DotNet.XHarness.Apple/AppOperations/AppRunnerBase.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,11 @@ private CancellationTokenSource CaptureLogStream(string appName, bool useSimctl,
327327
}
328328
else
329329
{
330+
// For MacCatalyst, the test output log does not propagate to the main log.
331+
// Hence, we duplicate the log to the main console log to simplify the UX of failure investigation.
332+
IFileBackedLog aggregatedAppOutputLog = Log.CreateReadableAggregatedLog(_mainLog, log);
330333
_processManager
331-
.ExecuteCommandAsync("log", logArgs, _mainLog, log, log, TimeSpan.FromDays(1), cancellationToken: streamCancellation)
334+
.ExecuteCommandAsync("log", logArgs, _mainLog, aggregatedAppOutputLog, aggregatedAppOutputLog, TimeSpan.FromDays(1), cancellationToken: streamCancellation)
332335
.DoNotAwait();
333336
}
334337

src/Microsoft.DotNet.XHarness.Apple/AppOperations/AppTester.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ public AppTester(
190190
using var crashLogs = new Logs(_logs.Directory);
191191

192192
ICrashSnapshotReporter crashReporter = _snapshotReporterFactory.Create(_mainLog, crashLogs, isDevice: !isSimulator, device.Name);
193-
using ITestReporter testReporter = _testReporterFactory.Create(_mainLog,
193+
using ITestReporter testReporter = _testReporterFactory.Create(
194+
_mainLog,
194195
_mainLog,
195196
_logs,
196197
crashReporter,
@@ -361,11 +362,15 @@ private async Task RunDeviceTests(
361362
// We need to check for MT1111 (which means that mlaunch won't wait for the app to exit)
362363
IFileBackedLog aggregatedLog = Log.CreateReadableAggregatedLog(_mainLog, testReporter.CallbackLog);
363364

365+
// The app output log is not directly accessible.
366+
// Hence, we duplicate the log to the main console log to simplify the UX of failure investigation.
367+
IFileBackedLog aggregatedAppOutputLog = Log.CreateReadableAggregatedLog(_mainLog, appOutputLog);
368+
364369
var result = await RunAndWatchForAppSignal(() => _processManager.ExecuteCommandAsync(
365370
mlaunchArguments,
366371
aggregatedLog,
367-
appOutputLog,
368-
appOutputLog,
372+
aggregatedAppOutputLog,
373+
aggregatedAppOutputLog,
369374
timeout,
370375
envVars,
371376
cancellationToken: cancellationToken));

0 commit comments

Comments
 (0)