Returns a log level for a given response.

@param RequestInterface $request The request being logged.

@return string LogLevel
180799
protected function getLogLevel(RequestInterface $request)
    {
        if (!$this->logLevel) {
            return $this->getDefaultLogLevel();
        }

        if (is_callable($this->logLevel)) {
            return call_user_func($this->logLevel, $request);
        }

        return (string) $this->logLevel;
    }
67620
public function getTokenFromRequest( RequestInterface $request ) {
		if ( $request->get( $this->key ) ) {
			return $request->get( $this->key );
		}

		if ( $request->post( $this->key ) ) {
			return $request->post( $this->key );
		}

		if ( $request->headers( $this->header ) ) {
			return $request->headers( $this->header );
		}

		return '';
	}
835462
public function logs(ServerRequestInterface $request): ResponseInterface
    {
        $earliest = DB::table('log')->min('log_time');
        $latest   = DB::table('log')->max('log_time');

        $earliest = $earliest ? Carbon::make($earliest) : Carbon::now();
        $latest   = $latest ? Carbon::make($latest) : Carbon::now();

        $earliest = $earliest->toDateString();
        $latest   = $latest->toDateString();

        $action   = $request->get('action', '');
        $from     = $request->get('from', $earliest);
        $to       = $request->get('to', $latest);
        $type     = $request->get('type', '');
        $text     = $request->get('text', '');
        $ip       = $request->get('ip', '');
        $username = $request->get('username', '');
        $gedc     = $request->get('gedc');

        $from = max($from, $earliest);
        $to   = min(max($from, $to), $latest);

        $user_options = ['' => ''];
        foreach ($this->user_service->all() as $tmp_user) {
            $user_options[$tmp_user->userName()] = $tmp_user->userName();
        }

        $tree_options = ['' => ''] + Tree::getNameList();

        $title = I18N::translate('Website logs');

        return $this->viewResponse('admin/site-logs', [
            'action'       => $action,
            'earliest'     => $earliest,
            'from'         => $from,
            'gedc'         => $gedc,
            'ip'           => $ip,
            'latest'       => $latest,
            'tree_options' => $tree_options,
            'title'        => $title,
            'to'           => $to,
            'text'         => $text,
            'type'         => $type,
            'username'     => $username,
            'user_options' => $user_options,
        ]);
    }
1371067
public function request(RequestInterface $request)
    {
        $uri = $request->getUri()
            ->withPath('')
            ->withQuery('')
            ->withFragment('');

        $uri = $uri . $request->getRequestTarget();

        $request = $request->withRequestTarget($uri);

        return $this->doRequest($request);
    }
762845
public function next(RequestInterface $request)
    {
        if (!count($this->processingStack) && $this->responseSourceDelegate) {
            return $this->responseSourceDelegate->next($request);
        }
        return parent::next($request);
    }
1056216
public static function getContentCharset(RequestInterface $request): string
    {
        $contentType = $request->getHeaderLine('Content-Type');
        if (preg_match('/[^;]+; ?charset=(?P<charset>[^;]+);?.*/', $contentType, $matches)) {
            return $matches['charset'];
        }

        return '';
    }
349265
private function getSubmittedVersionNumber(RequestInterface $request)
    {
        $accept  = $request->getHeader('Accept');
        $matches = array();

        preg_match('/^application\/vnd\.([a-z.-_]+)\.v([\d]+)\+([a-z]+)$/', $accept, $matches);

        return isset($matches[2]) ? $matches[2] : null;
    }
429943
public function getFormattedQueryParameters(RequestInterface $request)
    {
        return $this->getString($this->getQueryParameters($request->getUri()->getQuery()));
    }
447195
private function getLogLevel()
    {
        switch (Environment::LOG_LEVEL) {
            case "emergency":
                $this->logLevel = 8;
                break;
            case "alert":
                $this->logLevel = 7;
                break;
            case "critical":
                $this->logLevel = 6;
                break;
            case "error":
                $this->logLevel = 5;
                break;
            case "warning":
                $this->logLevel = 4;
                break;
            case "notice":
                $this->logLevel = 3;
                break;
            case "info":
                $this->logLevel = 2;
                break;
            case "debug":
                $this->logLevel = 1;
                break;
            default:
                $this->logLevel = 1;
                break;
        }
    }
11922
public function getLogs(GetLogsRequest $request)
    {
        $headers = array();
        $params  = array();
        if ($request->getTopic() !== null) {
            $params ['topic'] = $request->getTopic();
        }
        if ($request->getFrom() !== null) {
            $params ['from'] = $request->getFrom();
        }
        if ($request->getTo() !== null) {
            $params ['to'] = $request->getTo();
        }
        if ($request->getQuery() !== null) {
            $params ['query'] = $request->getQuery();
        }
        $params ['type'] = 'log';
        if ($request->getLine() !== null) {
            $params ['line'] = $request->getLine();
        }
        if ($request->getOffset() !== null) {
            $params ['offset'] = $request->getOffset();
        }
        if ($request->getOffset() !== null) {
            $params ['reverse'] = $request->getReverse() ? 'true' : 'false';
        }

        $project  = $request->getProject() ?: '';
        $logStore = $request->getLogStore() ?: '';

        $resource = "/logstores/$logStore";
        list ( $resp, $header ) = $this->send("GET", $project, null, $resource, $params, $headers);

        $requestId = isset ( $header ['x-log-requestid'] ) ? $header ['x-log-requestid'] : '';
        $resp      = $this->parseToJson($resp, $requestId);

        return new GetLogsResponse ($resp, $header);
    }
23120
public static function getPath( RequestInterface $request ) {
		$url = $request->getUrl();
		$relative_url = substr( $url, strlen( home_url( '/' ) ) );
		$relative_url = static::addLeadingSlash( $relative_url );
		$relative_url = preg_replace( '~\?.*~', '', $relative_url );
		$relative_url = static::addTrailingSlash( $relative_url );
		return $relative_url;
	}
576154
public function getExceptionForFailedRequest(RequestInterface $request)
    {
        $oid = spl_object_hash($request);

        return isset($this->exceptionForRequest[$oid]) ? $this->exceptionForRequest[$oid] : null;
    }
553194
private function getLogLevel(Throwable $e): string
    {
        if ($e instanceof ErrorException && array_key_exists($e->getSeverity(), $this->levelMap)) {
            return $this->levelMap[$e->getSeverity()];
        }

        // default log level for Throwable
        return LogLevel::CRITICAL;
    }
880779
public function getLastRequestTime(RequestInterface $request)
    {
        $route = $this->getRoute($request);

        if (isset($this->routes[$route])) {
            return isset($this->routes[$route]['lastRequest']) ? $this->routes[$route]['lastRequest'] : null;
        }
    }
1006845
public function getParsedResponse(RequestInterface $request)
    {
        try {
            $response = $this->getResponse($request);
        } catch (BadResponseException $e) {
            $response = $e->getResponse();
        }

        $parsed = $this->parseResponse($response);

        $this->checkResponse($response, $parsed);

        return $parsed;
    }
128259
private function get_log_level( $level, $log_level ) {
		if ( ! isset( $log_level[ $level ] ) && ! isset( $log_level[''] ) ) {
			return 'info';
		}
		'' === $level || ! isset( $log_level[ $level ] ) and $level = $log_level[''];
		if ( empty( $log_level[ $level ] ) ) {
			return 'info';
		}

		return $level;
	}
430297
public function request(RequestInterface $request)
    {
        $response = $this->httpClient->sendRequest($request);
        $data = $this->decodeResponse($response);
        $this->detectError($data);

        return $data;
    }