If you want to debug your expect program, just add the code below at the very top of your program.
Notice the -d at the end of the line. That puts the expect in debug mode. Also, take note that your expect program may be in another path. The code above is just an example.
One of the previous developer forget to remove the -d parameter. So when the expect program runs in production, the log is too big. When the issue was raised to me, I didn’t have a clue. I’m not an Linux expert anyway. I just got lucky that I noticed that parameter on first line.