Is there any way to log when program returns control back to the main event loop?