From 95a2f0ab2b5381e77152acde48a0cfad276bec87 Mon Sep 17 00:00:00 2001 From: IhateTrains Date: Fri, 5 Jul 2024 16:19:04 +0100 Subject: [PATCH] Log Imperator's standard output and standard error if exit code is not 0 (#2048) #patch --- ImperatorToCK3/Imperator/World.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ImperatorToCK3/Imperator/World.cs b/ImperatorToCK3/Imperator/World.cs index 124e92a79..68fb9e346 100644 --- a/ImperatorToCK3/Imperator/World.cs +++ b/ImperatorToCK3/Imperator/World.cs @@ -174,6 +174,7 @@ private void LaunchImperatorToExportCountryFlags(Configuration config) { Arguments = "-continuelastsave -debug_mode", CreateNoWindow = true, RedirectStandardOutput = true, + RedirectStandardError = true, WindowStyle = ProcessWindowStyle.Hidden }; var imperatorProcess = Process.Start(processStartInfo); @@ -217,6 +218,10 @@ private void LaunchImperatorToExportCountryFlags(Configuration config) { private static EventHandler HandleImperatorProcessExit(Configuration config, Process imperatorProcess) { return (_, _) => { Logger.Debug($"Imperator process exited with code {imperatorProcess.ExitCode}. Removing temporary mod files..."); + if (imperatorProcess.ExitCode != 0) { + Logger.Debug("Imperator standard output: " + imperatorProcess.StandardOutput.ReadToEnd()); + Logger.Debug("Imperator standard error: " + imperatorProcess.StandardError.ReadToEnd()); + } try { File.Delete(Path.Combine(config.ImperatorDocPath, "mod/coa_export_mod.mod")); Directory.Delete(Path.Combine(config.ImperatorDocPath, "mod/coa_export_mod"), recursive: true);