Everything in your code is synchronous. You don't need to rely on the logs for anything.
mqtt_connect
another_program
If and only if mqtt_connect has completed successfully then another_program will be executed.
This doesn't mean that the connection was actually established. You need to handle the Connected event (or better wait for it with Wait For).