def truncate(string, max_len=1000):
    """returns a truncated to max_len version of a string (or str(string))"""
    string = str(string)
    if len(string) > max_len - 12:
        return string[:max_len] + '...TRUNCATED'
    return string
