Ejemplo n.º 1
0
 def _reset(self):
     """Internal version of reset() with no locking."""
     contents = self._contents()
     self._bytes = len(contents)
     self._lines = len(contents.split('\n')) - 1
     self._flush_time = time.time()
     self._request = logsutil.RequestID()
Ejemplo n.º 2
0
  def _write(self, line):
    """Writes a line to the logs buffer."""
    if self._request != logsutil.RequestID():


      self._reset()

    if line:
      if self._buffer and not self._buffer[-1].IsComplete():



        record = self._buffer.pop()
        self._bytes -= len(record)
        record.message += line








        self._buffer.append(logsutil.StderrRecord(''))
      else:
        record = logsutil.RecordFromLine(line)
      self._buffer.append(record)
      self._bytes += len(record)
    self._autoflush()
Ejemplo n.º 3
0
    def _write(self, line):
        """Writes a line to the logs buffer."""
        if self._request != logsutil.RequestID():

            self._reset()
        self._put_line(line)
        self._autoflush()
Ejemplo n.º 4
0
    def _write(self, line):
        """Writes a line to the logs buffer."""
        if self._request != logsutil.RequestID():

            self._reset()
        self.stream().write(line)

        self._lines += 1
        self._bytes += len(line)
        self._autoflush()
Ejemplo n.º 5
0
    def write_record(self, level, created, message, source_location=None):

        message = cleanup_message(message)
        with self._lock:
            if self._request != logsutil.RequestID():

                self._reset()
            record = logsutil.LoggingRecord(level, long(created * 1000 * 1000),
                                            message, source_location)
            self._buffer.append(record)
            self._bytes += len(record)
            self._autoflush()
Ejemplo n.º 6
0
def log_request(request, add_params=True, **kwargs):
  """Adds an error. This should be used normally."""
  kwargs['endpoint'] = request.path
  kwargs['method'] = request.method
  kwargs['request_id'] = logsutil.RequestID()
  kwargs['source_ip'] = request.remote_addr
  if add_params:
    kwargs['params'] = request.params.mixed()
    try:
      as_json = request.json
      if isinstance(as_json, dict):
        kwargs['params'].update(as_json)
    except (LookupError, TypeError, ValueError):
      pass
  return log(**kwargs)
Ejemplo n.º 7
0
 def _reset(self):
     """Internal version of reset() with no locking."""
     self._bytes = sum(len(record) for record in self._buffer)
     self._flush_time = time.time()
     self._request = logsutil.RequestID()