API::logEndpointUsage PHP Method

logEndpointUsage() private method

Log usage of the api into glpi historical or log files (defined by api config) It stores the ip and the username of the current session.
private logEndpointUsage ( $endpoint = "" )
$endpoint string function called by api to log (default '')
    private function logEndpointUsage($endpoint = "")
    {
        $username = "";
        if (isset($_SESSION['glpiname'])) {
            $username = "(" . $_SESSION['glpiname'] . ")";
        }
        $apiclient = new APIClient();
        if ($apiclient->getFromDB($this->apiclients_id)) {
            $changes[0] = 0;
            $changes[1] = "";
            $changes[2] = "Enpoint '{$endpoint}' called by " . $this->iptxt . " {$username}";
            switch ($apiclient->fields['dolog_method']) {
                case APIClient::DOLOG_HISTORICAL:
                    Log::history($this->apiclients_id, 'APIClient', $changes, 0, Log::HISTORY_LOG_SIMPLE_MESSAGE);
                    break;
                case APIClient::DOLOG_LOGS:
                    Toolbox::logInFile("api", $changes[2] . "\n");
                    break;
            }
        }
    }