@staticmethod
def _all_cut_string(string, max_length, logger):
    """Cuts string data to the maximum length allowed in a pytables column
        if string is too long.

        :param string: String to be cut
        :param max_length: Maximum allowed string length
        :param logger: Logger where messages about truncating should be written

        :return: String, cut if too long

        """
    if len(string) > max_length:
        logger.debug(
            'The string `%s` was too long I truncated it to %d characters' %
            (string, max_length))
        string = string[0:max_length - 3] + '...'.encode('utf-8')
    return string
