Log writing for debugging