def METHOD_NAME(self, x, level):
    s = __builtin__.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