stream: properly handling errors in the log writer thread