The idea of the log file is still a good one. Here is a sample of how:

$Ret = RedirectOutput("filename.txt, 1)
"@Time Connecting L: drive to share \\TX-Something..." ?

You can place these text strings before and after pieces of code. See if that helps.