Rereading my post I realize that I was very unclear as to what I was seeing. I was assuming only the evidence you had for a restart was the logger script. If I was wrong then please supply any other logs you may have. Seeing that the logger was flawed I assumed that cleaning up the logger would give a clearer picture of what was happening. I saw nothing in what you had posted to convince me it wasn't a logger problem. Are you saying that some problem manifests itself even without the posted logger script running?? You'll have to excuse me in that I was a bit myopic in focusing on the code that was posted.
Could you, please, post the code in the host machine that calls the suspected module?