diff --git a/cmd/launcher/svc_windows.go b/cmd/launcher/svc_windows.go index 5dc5bb868..712439256 100644 --- a/cmd/launcher/svc_windows.go +++ b/cmd/launcher/svc_windows.go @@ -55,16 +55,14 @@ func runWindowsSvc(systemSlogger *multislogger.MultiSlogger, args []string) erro logger := log.NewNopLogger() if opts.RootDirectory != "" { + rootDirectoryChanged := false + optsRootDirectory := opts.RootDirectory // check for old root directories before creating DB in case we've stomped over with windows MSI install updatedRootDirectory := determineRootDirectory(systemSlogger.Logger, opts) if updatedRootDirectory != opts.RootDirectory { - systemSlogger.Log(context.TODO(), slog.LevelInfo, - "old root directory contents detected, overriding opts.RootDirectory", - "opts_root_directory", opts.RootDirectory, - "updated_root_directory", updatedRootDirectory, - ) - opts.RootDirectory = updatedRootDirectory + // cache that we did this so we can log to debug.json when set up below + rootDirectoryChanged = true } // Create a local logger. This logs to a known path, and aims to help diagnostics @@ -80,6 +78,14 @@ func runWindowsSvc(systemSlogger *multislogger.MultiSlogger, args []string) erro // also write system logs to localSloggerHandler systemSlogger.AddHandler(localSloggerHandler) + + if rootDirectoryChanged { + localSlogger.Log(context.TODO(), slog.LevelInfo, + "old root directory contents detected, overriding opts.RootDirectory", + "opts_root_directory", optsRootDirectory, + "updated_root_directory", updatedRootDirectory, + ) + } } // Confirm that service configuration is up-to-date