Debug Logging During New Plugin Development

I’m still in the process of understanding the flow of execution for when a desired program is launched using AYON launcher.

The earliest point that I can trace back is at the ApplicationLaunchContext.launch function from ayon-applications\client\ayon_applications\manager.py.

This is where the prelaunch hooks the process and the launch hook is run.

I’m relying on the log messaged displayed in ayon_console to understand this better. Currently, running ayon_console with --debug --use-dev, I can see all the logs and print statements in this console until the ApplicationLaunchContext._run_process function is executed and open the desired program.

In my case, here is what the subprocess.Popen execute:

path_to_payon/ayon_console.exe run DEV_FOLDER\ayon\ayon-storyboardpro\client\ayon_storyboardpro\api\launch_script.py C:\Program Files (x86)\Toon Boom Animation\Toon Boom Storyboard Pro 24\win64\bin\StoryboardPro.exe path_to_the_sbp_file.sbpz

Any log message that I’ve put into launch_script.py is now outputted to the newly spawned ayon_console progress other than the original one. When ApplicationLaunchContext is initialized, the “creationflags” are set to subprocess.CREATE_NEW_PROCESS_GROUP | subprocess.DETACHED_PROCESS when developer is on windows os.

The work around to still see the logs from the target program is to remove creationflags from the self.kwargs.

The down side of this method is ayon_console is now that parent process of the target program (i.e. Storyboard Pro), which means that closing ayon_console will also close the target program. This is undesirable since it increase the risk of the target program crash or become unresponsive.

For new developers, what is the best way to see the logs from the whole life time of a program when it’s launched via AYON launcher?

Development is always related to the specific DCC and it’s launch logic as it’s not always the same. And it’s kinda a work of a develop to be able to set it to development “state”. And it should not affect artists, so it might not be always in the code directly.

@Petr_Kalis might help here, but I’m afraid in this case you’ll have to find your own way as Harmony is not in live development now. You can also try to use CREATE_NEW_CONSOLE frag, which still should run detached process, but with console.

1 Like