NEW Add option MAIN_API_DEBUG to save API logs into a file

This commit is contained in:
Laurent Destailleur 2022-03-18 14:09:53 +01:00
parent 60d9db248f
commit ef21def5ce
2 changed files with 23 additions and 0 deletions

View File

@ -158,6 +158,25 @@ if (!empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $
$api = new DolibarrApi($db, '', $refreshcache);
//var_dump($api->r->apiVersionMap);
// If MAIN_API_DEBUG is set to 1, we save logs into file "dolibarr_api.log"
if (!empty($conf->global->MAIN_API_DEBUG)) {
$r = $api->r;
$r->onCall(function () use ($r) {
// Don't log Luracast Restler Explorer recources calls
//if (!preg_match('/^explorer/', $r->url)) {
// 'method' => $api->r->requestMethod,
// 'url' => $api->r->url,
// 'route' => $api->r->apiMethodInfo->className.'::'.$api->r->apiMethodInfo->methodName,
// 'version' => $api->r->getRequestedApiVersion(),
// 'data' => $api->r->getRequestData(),
//dol_syslog("Debug API input ".var_export($r, true), LOG_DEBUG, 0, '_api');
dol_syslog("Debug API url ".var_export($r->url, true), LOG_DEBUG, 0, '_api');
dol_syslog("Debug API input ".var_export($r->getRequestData(), true), LOG_DEBUG, 0, '_api');
//}
});
}
// Enable the Restler API Explorer.
// See https://github.com/Luracast/Restler-API-Explorer for more info.
$api->r->addAPIClass('Luracast\\Restler\\Explorer');

View File

@ -91,6 +91,10 @@ INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (154,
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (154, '15419', '626 - Régimen Simplificado de Confianza', 1);
ALTER TABLE llx_partnership ADD UNIQUE INDEX uk_fk_type_fk_soc (fk_type, fk_soc, date_partnership_start);
ALTER TABLE llx_partnership ADD UNIQUE INDEX uk_fk_type_fk_member (fk_type, fk_member, date_partnership_start);
-- v16
ALTER TABLE llx_projet_task_time ADD COLUMN fk_product integer NULL;