code: def _FormatValue(self, value, level=0):
      
  
      def FormatDictItem(key_value):
        """Formats single dictionary item."""
        key, value = key_value
        return (self._FormatValue(key, level + 1) +
                ': ' +
                self._FormatValue(value, level + 1))
  
      def LimitedEnumerate(items, formatter, level=0):
        """Returns items in the specified enumerable enforcing threshold."""
        count = 0
        limit = self.max_sublist_items if level > 0 else self.max_list_items
        for item in items:
          if count == limit:
            yield '...'
            break
  
          yield formatter(item)
          count += 1
  
      def FormatList(items, formatter, level=0):
        """Formats a list using a custom item formatter enforcing threshold."""
        return ', '.join(LimitedEnumerate(items, formatter, level=level))
  
      if isinstance(value, _PRIMITIVE_TYPES):
        return _TrimString(repr(value),  # Primitive type, always immutable.
                           self.max_value_len)
  
      if isinstance(value, _DATE_TYPES):
        return str(value)
  
      if level > self.max_depth:
        return str(type(value))
  
      if isinstance(value, dict):
        return '{' + FormatList(six.iteritems(value), FormatDictItem) + '}'
  
      if isinstance(value, _VECTOR_TYPES):
        return _ListTypeFormatString(value).format(FormatList(
            value, lambda item: self._FormatValue(item, level + 1), level=level))
  
      if isinstance(value, types.FunctionType):
        return 'function ' + value.__name__
  
      if hasattr(value, '__dict__') and value.__dict__:
        return self._FormatValue(value.__dict__, level)
  
      return str(type(value))
docs: Pretty-prints an object for a logger.
  
      This function is very similar to the standard pprint. The main difference
      is that it enforces limits to make sure we never produce an extremely long
      string or take too much time.
  
      Args:
        value: Python object to print.
        level: current recursion level.
  
      Returns:
        Formatted string.