def __obj2json(self, obj):
        """Serialize obj to a JSON formatted string.

        This is useful for pretty printing log records in the console.
        """
        return json.dumps(obj, indent=self._indent, sort_keys=self._sort_keys)