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

        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()
968947
protected void forcedLog(String fqcn, Priority level, Object message, Throwable t) {
        callAppenders(new LoggingEvent(fqcn, this, level, message, t));
    }
454783
def stream_logs(self, stdout=True, stderr=True, tail='all', timeout=10.0):
        
        return stream_logs(
            self.inner(), stdout=stdout, stderr=stderr, tail=tail,
            timeout=timeout)
140884
def start(self):
        ''''''
        self._configs = self._client.config_get('slow-*')
        self._client.config_set('slowlog-max-len', 100000)
        self._client.config_set('slowlog-log-slower-than', 0)
        self._client.execute_command('slowlog', 'reset')
430967
def handle_log_data(self, m):
        ''''''
        if self.download_file is None:
            return
        # lose some data
        # import random
        # if random.uniform(0,1) < 0.05:
        #    print('dropping ', str(m))
        #    return
        if m.ofs != self.download_ofs:
            self.download_file.seek(m.ofs)
            self.download_ofs = m.ofs
        if m.count != 0:
            s = bytearray(m.data[:m.count])
            self.download_file.write(s)
            self.download_set.add(m.ofs // 90)
            self.download_ofs += m.count
        self.download_last_timestamp = time.time()
        if m.count == 0 or (m.count < 90 and len(self.download_set) == 1 + (m.ofs // 90)):
            dt = time.time() - self.download_start
            self.download_file.close()
            size = os.path.getsize(self.download_filename)
            speed = size / (1000.0 * dt)
            print("Finished downloading %s (%u bytes %u seconds, %.1f kbyte/sec %u retries)" % (
                self.download_filename,
                size,
                dt, speed,
                self.retries))
            self.download_file = None
            self.download_filename = None
            self.download_set = set()
            self.master.mav.log_request_end_send(self.target_system,
                                                 self.target_component)
            if len(self.download_queue):
                self.log_download_next()
65705
protected boolean throttleRequest(final HttpServletRequest request, final HttpServletResponse response) {
        return configurationContext.getThrottledRequestExecutor() != null
            && configurationContext.getThrottledRequestExecutor().throttle(request, response);
    }
842317
def close_session_log(self):
        """"""
        if self.session_log is not None and self._session_log_close:
            self.session_log.close()
            self.session_log = None
820150
private synchronized void ungetLogService() {
        doWarnIfClosed = doDebug();
        if (log != null) {
            bc.ungetService(logSR);
            logSR = null;
            log = null;
        }
    }
1082357
private void silenceHiveLoggers() {
    List<String> loggers = ImmutableList.of("org.apache.hadoop.hive", "org.apache.hive", "hive.ql.parse");
    for (String name : loggers) {
      Logger logger = Logger.getLogger(name);
      if (logger != null) {
        logger.setLevel(Level.WARN);
      }
    }
  }
185280
def _teardown_log_prefix(self):
        """"""
        self._logger_console_fmtter.prefix = ''
        self._logger_console_fmtter.plugin_id = ''
        self._logger_file_fmtter.prefix = ' '
        self._logger_file_fmtter.plugin_id = ''
650739
def reduce(self, show_noisy=False):
        
        if not show_noisy:
            for log in self.quiet_logs:
                yield log['raw'].strip()
        else:
            for log in self.noisy_logs:
                yield log['raw'].strip()
980879
def _log_disconnect(self):
        """"""
        if self.logged:
            self.server.stats.on_conn_closed()
            self.logged = False
1151956
private void throttledTransfer(MockResponse policy, Socket socket, BufferedSource source,
      BufferedSink sink, long byteCount, boolean isRequest) throws IOException {
    if (byteCount == 0) return;

    Buffer buffer = new Buffer();
    long bytesPerPeriod = policy.getThrottleBytesPerPeriod();
    long periodDelayMs = policy.getThrottlePeriod(TimeUnit.MILLISECONDS);

    long halfByteCount = byteCount / 2;
    boolean disconnectHalfway = isRequest
        ? policy.getSocketPolicy() == DISCONNECT_DURING_REQUEST_BODY
        : policy.getSocketPolicy() == DISCONNECT_DURING_RESPONSE_BODY;

    while (!socket.isClosed()) {
      for (long b = 0; b < bytesPerPeriod; ) {
        // Ensure we do not read past the allotted bytes in this period.
        long toRead = Math.min(byteCount, bytesPerPeriod - b);
        // Ensure we do not read past halfway if the policy will kill the connection.
        if (disconnectHalfway) {
          toRead = Math.min(toRead, byteCount - halfByteCount);
        }

        long read = source.read(buffer, toRead);
        if (read == -1) return;

        sink.write(buffer, read);
        sink.flush();
        b += read;
        byteCount -= read;

        if (disconnectHalfway && byteCount == halfByteCount) {
          socket.close();
          return;
        }

        if (byteCount == 0) return;
      }

      if (periodDelayMs != 0) {
        try {
          Thread.sleep(periodDelayMs);
        } catch (InterruptedException e) {
          throw new AssertionError(e);
        }
      }
    }
  }
543042
def flush(self):
        """"""
        if self.__logFileStream is not None:
            try:
                self.__logFileStream.flush()
            except:
                pass
            try:
                os.fsync(self.__logFileStream.fileno())
            except:
                pass
        if self.__stdout is not None:
            try:
                self.__stdout.flush()
            except:
                pass
            try:
                os.fsync(self.__stdout.fileno())
            except:
                pass
1003024
protected function sleep(){
        flush();
        $s = ($this->throttleTime == 1) ? '' : 's';
        $this->log("Request was throttled, Sleeping for ".$this->throttleTime." second$s",'Throttle');
        sleep($this->throttleTime);
    }
289850
def handle_log_data_missing(self):
        ''''''
        if len(self.download_set) == 0:
            return
        highest = max(self.download_set)
        diff = set(range(highest)).difference(self.download_set)
        if len(diff) == 0:
            self.master.mav.log_request_data_send(self.target_system,
                                                       self.target_component,
                                                       self.download_lognum, (1 + highest) * 90, 0xffffffff)
            self.retries += 1
        else:
            num_requests = 0
            while num_requests < 20:
                start = min(diff)
                diff.remove(start)
                end = start
                while end + 1 in diff:
                    end += 1
                    diff.remove(end)
                self.master.mav.log_request_data_send(self.target_system,
                                                           self.target_component,
                                                           self.download_lognum, start * 90, (end + 1 - start) * 90)
                num_requests += 1
                self.retries += 1
                if len(diff) == 0:
                    break
1105462
def verbose(self, msg, *args, **kw):
        """"""
        if self.isEnabledFor(VERBOSE):
            self._log(VERBOSE, msg, args, **kw)