def _log(self, level, msg, args, kwargs):
        """Throttled log output."""

        with self._tb_lock:
            if self._tb is None:
                throttled = 0
                should_log = True
            else:
                throttled = self._tb.throttle_count
                should_log = self._tb.check_and_consume()

        if should_log:
            if throttled > 0:
                self._logger.log(level, "")
                self._logger.log(
                    level,
                    "(... throttled %d messages ...)",
                    throttled,
                )
                self._logger.log(level, "")

            if msg is not None:
                self._logger.log(level, msg, *args, **kwargs)

            return FancyLogContext(self._logger,
                                   level,
                                   self._verbosity,
                                   self._structured_detail,
                                   self._with_prefix)
        else:
            return NoopLogContext()
Throttled log output.