def METHOD_NAME(self, x, level):
    s = builtins.repr(x) # XXX Hope this isn't too slow...
    if len(s) > self.maxlong:
        i = max(0, (self.maxlong-3)//2)
        j = max(0, self.maxlong-3-i)
        s = s[:i] + '...' + s[len(s)-j:]
    return s