def _openFile(self):
        """
        Open the log file.

        The log file is always opened in binary mode.
        """
        self.closed = False
        if os.path.exists(self.path):
            self._file = open(self.path, "rb+", 0)
            self._file.seek(0, 2)
        else:
            if self.defaultMode is not None:
                # Set the lowest permissions
                oldUmask = os.umask(0o777)
                try:
                    self._file = open(self.path, "wb+", 0)
                finally:
                    os.umask(oldUmask)
            else:
                self._file = open(self.path, "wb+", 0)
        if self.defaultMode is not None:
            try:
                os.chmod(self.path, self.defaultMode)
            except OSError:
                # Probably /dev/null or something?
                pass

        Open the log file.

        The log file is always opened in binary mode.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/logfile.py