Redirect the stdout to a log file.

def stdout_cm(self):
        """ Redirect the stdout to a log file. """
        with open(self._get_stdout_log(), 'a+') as fh:
            msg = '### {} ###\n'.format(self._datetime)
            fh.write(msg)
            fh.flush()

            yield fh