Log an http based api call.

    Args:
      request: A WSGI request object.
      response: A WSGI response object.
776230
def LogHttpAdminUIAccess(self, request, response):
    
    # TODO(user): generate event_id elsewhere and use it for all the log
    # messages that have to do with handling corresponding request.
    event_id = self.GetNewEventId()

    api_method = response.headers.get("X-API-Method", "unknown")
    api_reason = response.headers.get("X-GRR-Reason", "none")
    log_msg = "%s API call [%s] by %s (reason: %s): %s [%d]" % (
        event_id, api_method, request.user, api_reason, request.full_path,
        response.status_code)
    logging.info(log_msg)

    if response.headers.get("X-No-Log") != "True":
      if data_store.RelationalDBEnabled():
        entry = rdf_objects.APIAuditEntry.FromHttpRequestResponse(
            request, response)
        data_store.REL_DB.WriteAPIAuditEntry(entry)
1318423
def _process_response(self, request, response):
        """"""
        log_format = self._get_log_format(request)
        if not log_format:
            return response

        params = self._get_parameters_from_request(request)
        # log a message displayed to user
        messages = django_messages.get_messages(request)
        result_message = None
        if messages:
            result_message = ', '.join('%s: %s' % (message.tags, message)
                                       for message in messages)
        elif 'action' in request.POST:
            result_message = request.POST['action']
        params['message'] = result_message
        params['http_status'] = response.status_code

        self.OPERATION_LOG.info(log_format, params)

        return response
703778
def _log_error(self, request, error):
        ''''''
        _logger.error(
            _('Fetching ‘{url}’ encountered an error: {error}'),
            url=request.url, error=error
        )
67226
def log_request(
        self, request: str, trim_log_values: bool = False, **kwargs: Any
    ) -> None:
        
        return log_(request, request_log, "info", trim=trim_log_values, **kwargs)
644894
def http_response(self, request):
        '''
        '''
        content_types = request.content_types
        if not content_types or self._content_type in content_types:
            response = request.response
            response.content_type = self._content_type
            response.encoding = self.charset
            response.content = self.to_bytes()
            return response
        else:
            raise HttpException(status=415, msg=request.content_types)
821061
def log_request(self, code="-", size="-"):
        
        self._service.log(logging.DEBUG, '"%s" %s', self.requestline, code)
423607
def _request_api(self, **kwargs):
        
        _url = kwargs.get('url')
        _method = kwargs.get('method', 'GET')
        _status = kwargs.get('status', 200)

        counter = 0
        if _method not in ['GET', 'POST']:
            raise ValueError('Method is not GET or POST')

        while True:
            try:
                res = REQ[_method](_url, cookies=self._cookie)
                if res.status_code == _status:
                    break
                else:
                    raise BadStatusException(res.content)
            except requests.exceptions.BaseHTTPError:
                if counter < self._retries:
                    counter += 1
                    continue
                raise MaxRetryError
        self._last_result = res
        return res
521621
def get_response(wsgi_request):
    '''
        
    '''
    service_start_time = datetime.now()
    # Get the view / handler for this request
    view, args, kwargs = resolve(wsgi_request.path_info)

    kwargs.update({"request": wsgi_request})

    # Let the view do his task.
    try:
        resp = view(*args, **kwargs)
    except Exception as exc:
        resp = HttpResponseServerError(content=exc.message)

    headers = dict(resp._headers.values())
    # Convert HTTP response into simple dict type.
    d_resp = {"status_code": resp.status_code, "reason_phrase": resp.reason_phrase,
              "headers": headers}
    try:
        d_resp.update({"body": resp.content})
    except ContentNotRenderedError:
        resp.render()
        d_resp.update({"body": resp.content})

    # Check if we need to send across the duration header.
    if _settings.ADD_DURATION_HEADER:
        d_resp['headers'].update({_settings.DURATION_HEADER_NAME: (datetime.now() - service_start_time).seconds})

    return d_resp
331486
def get_log(self, request, response):
        
        return {
            'method': request.method,
            'path': request.get_full_path(),
            'code': response.status_code,
            'time': time.time(),
        }
499904
function log(requester, level) {
    var context = requester.context;
    var logger = context.data.logger;
    if (!logger || !logger[level]) {
        return;
    }

    var args = Array.prototype.slice.call(arguments, 2);
    args[0] = 'AJAX-' + requester.uid + ' ' + args[0];
    logger[level].apply(logger, args);
}
793124
function logRequest(err, res) {
    if (res) {
      let ms = new Date() - res.requestStartTime;

      var time = ms < 1000 ? `${ms}ms` : `${(ms/1000).toFixed(2)}s`;

      logRoute(`${res.req.method} ${res.statusCode} (${time}): ${res.req.originalUrl}`);
    }
  }
870374
def run(request)
      util = logger
      util.debug { request.log_string }
      response = request.run(raw_connection)
      util.debug { response.status.to_s }
      response
    end
161139
def callback_log(callback, api_key):
    
    params = {'key': api_key, 'callback': callback}
    resource = 'v2/receive/callback_log?' + util.urlencode(params)
    resp = util.call_api(resource, base_url='https://api.blockchain.info/')
    json_resp = json.loads(resp)
    return [LogEntry(e['callback'], e['called_at'], e['raw_response'], e['response_code']) for e in json_resp]
201873
public void log(HttpRequest request,
                    HttpResponse response,
                    int responseLength)
    {
        try{
            // ignore ignorables
            if (_ignorePathMap != null &&
                _ignorePathMap.getMatch(request.getPath()) != null)
                return;

            // log the rest
            if (_fileOut==null)
                return;

            StringBuffer buf = new StringBuffer(160);
            
            String addr = null;
            if(_preferProxiedForAddress)
            {
                // If header is not present, addr will remain null ...
                addr = request.getField(HttpFields.__XForwardedFor);
            }
            if(addr == null)
                addr = request.getRemoteAddr();
            buf.append(addr);
            
            buf.append(" - ");
            String user = request.getAuthUser();
            buf.append((user==null)?"-":user);
            buf.append(" [");
            buf.append(_logDateCache.format(request.getTimeStamp()));
            buf.append("] \"");
            buf.append(request.getMethod());
            buf.append(' ');
            buf.append(request.getURI());
            buf.append(' ');
            buf.append(request.getVersion());
            buf.append("\" ");
            int status=response.getStatus();    
            buf.append((char)('0'+((status/100)%10)));
            buf.append((char)('0'+((status/10)%10)));
            buf.append((char)('0'+(status%10)));
            if (responseLength>=0)
            {
                buf.append(' ');
                if (responseLength>99999)
                    buf.append(Integer.toString(responseLength));
                else
                {
                    if (responseLength>9999) 
                        buf.append((char)('0'+((responseLength/10000)%10)));
                    if (responseLength>999) 
                        buf.append((char)('0'+((responseLength/1000)%10)));
                    if (responseLength>99) 
                        buf.append((char)('0'+((responseLength/100)%10)));
                    if (responseLength>9) 
                        buf.append((char)('0'+((responseLength/10)%10)));
                    buf.append((char)('0'+(responseLength%10)));
                }
                buf.append(' ');
            }
            else
                buf.append(" - ");

            String log =buf.toString();
            synchronized(_writer)
            {
                _writer.write(log);
                if (_extended)
                {
                    logExtended(request,response,_writer);
                    if (!_logCookies)
                        _writer.write(" -");
                }
                
                if (_logCookies)
                {
                    Cookie[] cookies = request.getCookies();
                    if (cookies==null || cookies.length==0)
                        _writer.write(" -");
                    else
                    {
                        _writer.write(" \"");
                        for (int i=0;i<cookies.length;i++)
                        {
                            if (i!=0)
                                _writer.write(';');
                            _writer.write(cookies[i].getName());
                            _writer.write('=');
                            _writer.write(cookies[i].getValue());
                        }
                        _writer.write("\"");
                    }
                }
                
                if (_logLatency)
                    _writer.write(" "+(System.currentTimeMillis()-request.getTimeStamp()));
                
                _writer.write(StringUtil.__LINE_SEPARATOR);
                _writer.flush();
            }
        }
        catch(IOException e)
        {
            log.warn(LogSupport.EXCEPTION,e);
        }
    }
1340043
def process_request(self, request):
        
        # Initialize thread local storage
        threadlocal.auditlog = {
            'signal_duid': (self.__class__, time.time()),
            'remote_addr': request.META.get('REMOTE_ADDR'),
        }

        # In case of proxy, set 'original' address
        if request.META.get('HTTP_X_FORWARDED_FOR'):
            threadlocal.auditlog['remote_addr'] = request.META.get('HTTP_X_FORWARDED_FOR').split(',')[0]

        # Connect signal for automatic logging
        if hasattr(request, 'user') and is_authenticated(request.user):
            set_actor = curry(self.set_actor, user=request.user, signal_duid=threadlocal.auditlog['signal_duid'])
            pre_save.connect(set_actor, sender=LogEntry, dispatch_uid=threadlocal.auditlog['signal_duid'], weak=False)
506506
protected void log(HttpServletRequest httpRequest, String requestName, long duration,
			boolean systemError, int responseSize) {
		if (!logEnabled) {
			return;
		}
		final String filterName = filterConfig.getFilterName();
		LOG.logHttpRequest(httpRequest, requestName, duration, systemError, responseSize,
				filterName);
	}
958880
def send_response(self, code, message=None, size='-'):
        
        # pylint: disable-msg=W0221
        if self._to_log or LOG.isEnabledFor(logging.DEBUG):
            self.log_request(code, size)

        if message is None:
            if code in self.responses:
                message = self.responses[code][0]
            else:
                message = ''

        if self.request_version != 'HTTP/0.9':
            self.wfile.write("%s %d %s\r\n" %
                             ("HTTP/1.1", code, message))
        self.send_header('Server', self.version_string())
        self.send_header('Date', self.date_time_string())