Skip to content

Commit

Permalink
Log Imperator's standard output and standard error if exit code is no…
Browse files Browse the repository at this point in the history
…t 0 (#2048) #patch
  • Loading branch information
IhateTrains authored Jul 5, 2024
1 parent f99c150 commit 95a2f0a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ImperatorToCK3/Imperator/World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 95a2f0a

Please sign in to comment.