some log code for reference - may not apply cleanly. FILEWRITE_DEBUG_LOG needs to be implemented in platform, g7x and sx710 have examples.
My preferred way to use this is with chdkptp devutil
!require'extras/devutil'.init_cli()
dlstart
... do stuff ...
dlgetcam
Or if it crashes, the messages will in the cameralog.