This function shrinks a file.
    We remove only the middle part of a file,
    the file-start and the file-end remain unchanged.

def _reduce_file_size_if_necessary(fileName, maxSize):
    """
    This function shrinks a file.
    We remove only the middle part of a file,
    the file-start and the file-end remain unchanged.
    """
    fileSize = os.path.getsize(fileName)

    if maxSize is None:
        logging.debug("Size of logfile '%s' is %s bytes, size limit disabled.", fileName, fileSize)
        return # disabled, nothing to do

    if fileSize < (maxSize + 500):
        logging.debug("Size of logfile '%s' is %s bytes, nothing to do.", fileName, fileSize)
        return

    logging.warning("Logfile '%s' is too big (size %s bytes). Removing lines.", fileName, fileSize)
    util.shrink_text_file(fileName, maxSize, _LOG_SHRINK_MARKER)