From f5011bb200b02a48f95ab38aa47e543e3df2de77 Mon Sep 17 00:00:00 2001 From: jf-cbd Date: Thu, 13 Mar 2025 15:39:00 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B08260=20-=20Change=20format=20of=20REST?= =?UTF-8?q?=20logs=20when=20they=20are=20close=20to=20the=20SQL=20field=20?= =?UTF-8?q?size=20limit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webservices/rest.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/webservices/rest.php b/webservices/rest.php index c5a437cd4..e0cbfc081 100644 --- a/webservices/rest.php +++ b/webservices/rest.php @@ -299,7 +299,12 @@ if (MetaModel::GetConfig()->Get('log_rest_service')) $oLog->SetTrim('message', $sMessage); $oLog->Set('code', $oResult->code); $oResult->SanitizeContent(); - $oLog->SetTrim('json_output', json_encode($oResult, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); + $iUnescapeSlashAndUnicode = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE; + $sJsonOuputWithPrettyPrinting = json_encode($oResult, $iUnescapeSlashAndUnicode | JSON_PRETTY_PRINT); + $sJsonOutputWithoutPrettyPrinting = json_encode($oResult, $iUnescapeSlashAndUnicode); + !$oLog->StringFitsInField('json_output', $sJsonOuputWithPrettyPrinting) ? + $oLog->SetTrim('json_output', $sJsonOutputWithoutPrettyPrinting) : // too long, we don't make it pretty + $oLog->SetTrim('json_output', $sJsonOuputWithPrettyPrinting); $oLog->DBInsertNoReload(); } \ No newline at end of file