'Write to the log file.
:param msg: The text to write.'

def _write_to_file(self, msg, flush=False):

    if (self._file is None):
        return
    try:
        self._file.write(self._clean_string(msg))
    except Exception as e:
        self._file = None
        msg = 'An    exception    was    raised    while    trying    to    write    to    the    output    file    "%s",    error:    "%s".    Disabling    output    to    this    file.'
        om.out.error((msg % (self._output_file_name, e)), ignore_plugins=set([self.get_name()]))
    if (flush and (self._file is not None)):
        self._file.flush()
