Skip to content
Snippets Groups Projects
Commit bac05996 authored by Alex ORLUC's avatar Alex ORLUC
Browse files

FIX #17636 TIME 2 revert clean empty log pattern + improve fill log pattern

parent f869abe5
No related branches found
No related tags found
No related merge requests found
...@@ -131,11 +131,10 @@ function Bt_writeLog($args = []) ...@@ -131,11 +131,10 @@ function Bt_writeLog($args = [])
{ {
\SrcCore\controllers\LogsController::add([ \SrcCore\controllers\LogsController::add([
'isTech' => true, 'isTech' => true,
'moduleId' => $GLOBALS['batchName'], 'moduleId' => $GLOBALS['moduleId'],
'level' => $args['level'], 'level' => $args['level'],
'tableName' => '', 'tableName' => $GLOBALS['batchName'],
'recordId' => '', 'eventType' => 'script',
'eventType' => '',
'eventId' => $args['message'] 'eventId' => $args['message']
]); ]);
} }
......
...@@ -27,6 +27,7 @@ class IncludeFileError extends Exception ...@@ -27,6 +27,7 @@ class IncludeFileError extends Exception
// Globals variables definition // Globals variables definition
$GLOBALS['batchName'] = 'retrieveMailsFromSignatoryBook'; $GLOBALS['batchName'] = 'retrieveMailsFromSignatoryBook';
$GLOBALS['moduleId'] = 'externalSignatoryBook';
$GLOBALS['wb'] = ''; $GLOBALS['wb'] = '';
$totalProcessedResources = 0; $totalProcessedResources = 0;
......
...@@ -320,27 +320,23 @@ class FastParapheurController ...@@ -320,27 +320,23 @@ class FastParapheurController
{ {
$version = $args['version']; $version = $args['version'];
$GLOBALS['batchName'] = $GLOBALS['batchName'] ?? 'script';
foreach ($args['idsToRetrieve'][$version] as $resId => $value) { foreach ($args['idsToRetrieve'][$version] as $resId => $value) {
if (empty($value['res_id_master'])) { if (empty($value['res_id_master'])) {
LogsController::add([ LogsController::add([
'isTech' => true, 'isTech' => true,
'moduleId' => $GLOBALS['batchName'], 'moduleId' => $GLOBALS['moduleId'],
'level' => 'INFO', 'level' => 'INFO',
'tableName' => '', 'tableName' => $GLOBALS['batchName'],
'recordId' => '', 'eventType' => 'script',
'eventType' => '',
'eventId' => "Retrieve main document resId: ${resId}" 'eventId' => "Retrieve main document resId: ${resId}"
]); ]);
} else { } else {
LogsController::add([ LogsController::add([
'isTech' => true, 'isTech' => true,
'moduleId' => $GLOBALS['batchName'], 'moduleId' => $GLOBALS['moduleId'],
'level' => 'INFO', 'level' => 'INFO',
'tableName' => '', 'tableName' => $GLOBALS['batchName'],
'recordId' => '', 'eventType' => 'script',
'eventType' => '',
'eventId' => "Retrieve main document resId: ${resId}" 'eventId' => "Retrieve main document resId: ${resId}"
]); ]);
} }
...@@ -358,11 +354,10 @@ class FastParapheurController ...@@ -358,11 +354,10 @@ class FastParapheurController
LogsController::add([ LogsController::add([
'isTech' => true, 'isTech' => true,
'moduleId' => $GLOBALS['batchName'], 'moduleId' => $GLOBALS['moduleId'],
'level' => 'INFO', 'level' => 'INFO',
'tableName' => '', 'tableName' => $GLOBALS['batchName'],
'recordId' => '', 'eventType' => 'script',
'eventType' => '',
'eventId' => "Time limit reached ! Next retrieve time : {$newDate->format('d-m-Y H:i')}" 'eventId' => "Time limit reached ! Next retrieve time : {$newDate->format('d-m-Y H:i')}"
]); ]);
...@@ -381,11 +376,10 @@ class FastParapheurController ...@@ -381,11 +376,10 @@ class FastParapheurController
if (!empty($updateHistoryFetchDate['errors'])) { if (!empty($updateHistoryFetchDate['errors'])) {
LogsController::add([ LogsController::add([
'isTech' => true, 'isTech' => true,
'moduleId' => $GLOBALS['batchName'], 'moduleId' => $GLOBALS['moduleId'],
'level' => 'ERROR', 'level' => 'ERROR',
'tableName' => '', 'tableName' => $GLOBALS['batchName'],
'recordId' => '', 'eventType' => 'script',
'eventType' => '',
'eventId' => "{$updateHistoryFetchDate['errors']}" 'eventId' => "{$updateHistoryFetchDate['errors']}"
]); ]);
unset($args['idsToRetrieve'][$version][$resId]); unset($args['idsToRetrieve'][$version][$resId]);
...@@ -396,11 +390,10 @@ class FastParapheurController ...@@ -396,11 +390,10 @@ class FastParapheurController
if (!empty($historyResponse['errors'])) { if (!empty($historyResponse['errors'])) {
LogsController::add([ LogsController::add([
'isTech' => true, 'isTech' => true,
'moduleId' => $GLOBALS['batchName'], 'moduleId' => $GLOBALS['moduleId'],
'level' => 'ERROR', 'level' => 'ERROR',
'tableName' => '', 'tableName' => $GLOBALS['batchName'],
'recordId' => '', 'eventType' => 'script',
'eventType' => '',
'eventId' => "[fastParapheur api] {$historyResponse['errors']}" 'eventId' => "[fastParapheur api] {$historyResponse['errors']}"
]); ]);
unset($args['idsToRetrieve'][$version][$resId]); unset($args['idsToRetrieve'][$version][$resId]);
...@@ -411,11 +404,10 @@ class FastParapheurController ...@@ -411,11 +404,10 @@ class FastParapheurController
if ($valueResponse['stateName'] == $args['config']['data']['validatedState']) { if ($valueResponse['stateName'] == $args['config']['data']['validatedState']) {
LogsController::add([ LogsController::add([
'isTech' => true, 'isTech' => true,
'moduleId' => $GLOBALS['batchName'], 'moduleId' => $GLOBALS['moduleId'],
'level' => 'INFO', 'level' => 'INFO',
'tableName' => '', 'tableName' => $GLOBALS['batchName'],
'recordId' => '', 'eventType' => 'script',
'eventType' => '',
'eventId' => "Circuit ended ! Retrieve file from fastParapheur" 'eventId' => "Circuit ended ! Retrieve file from fastParapheur"
]); ]);
$response = FastParapheurController::download(['config' => $args['config'], 'documentId' => $value['external_id']]); $response = FastParapheurController::download(['config' => $args['config'], 'documentId' => $value['external_id']]);
...@@ -434,22 +426,20 @@ class FastParapheurController ...@@ -434,22 +426,20 @@ class FastParapheurController
if (!empty($proofDocument['errors'])) { if (!empty($proofDocument['errors'])) {
LogsController::add([ LogsController::add([
'isTech' => true, 'isTech' => true,
'moduleId' => $GLOBALS['batchName'], 'moduleId' => $GLOBALS['moduleId'],
'level' => 'ERROR', 'level' => 'ERROR',
'tableName' => '', 'tableName' => $GLOBALS['batchName'],
'recordId' => '', 'eventType' => 'script',
'eventType' => '',
'eventId' => "{$proofDocument['errors']}" 'eventId' => "{$proofDocument['errors']}"
]); ]);
continue; continue;
} elseif (!empty($proofDocument['encodedProofDocument'])) { } elseif (!empty($proofDocument['encodedProofDocument'])) {
LogsController::add([ LogsController::add([
'isTech' => true, 'isTech' => true,
'moduleId' => $GLOBALS['batchName'], 'moduleId' => $GLOBALS['moduleId'],
'level' => 'INFO', 'level' => 'INFO',
'tableName' => '', 'tableName' => $GLOBALS['batchName'],
'recordId' => '', 'eventType' => 'script',
'eventType' => '',
'eventId' => "Retrieve proof from fastParapheur" 'eventId' => "Retrieve proof from fastParapheur"
]); ]);
$args['idsToRetrieve'][$version][$resId]['log'] = $proofDocument['encodedProofDocument']; $args['idsToRetrieve'][$version][$resId]['log'] = $proofDocument['encodedProofDocument'];
...@@ -465,11 +455,10 @@ class FastParapheurController ...@@ -465,11 +455,10 @@ class FastParapheurController
} }
LogsController::add([ LogsController::add([
'isTech' => true, 'isTech' => true,
'moduleId' => $GLOBALS['batchName'], 'moduleId' => $GLOBALS['moduleId'],
'level' => 'INFO', 'level' => 'INFO',
'tableName' => '', 'tableName' => $GLOBALS['batchName'],
'recordId' => '', 'eventType' => 'script',
'eventType' => '',
'eventId' => "Done!" 'eventId' => "Done!"
]); ]);
break; break;
...@@ -492,11 +481,10 @@ class FastParapheurController ...@@ -492,11 +481,10 @@ class FastParapheurController
} }
LogsController::add([ LogsController::add([
'isTech' => true, 'isTech' => true,
'moduleId' => $GLOBALS['batchName'], 'moduleId' => $GLOBALS['moduleId'],
'level' => 'INFO', 'level' => 'INFO',
'tableName' => '', 'tableName' => $GLOBALS['batchName'],
'recordId' => '', 'eventType' => 'script',
'eventType' => '',
'eventId' => "Done!" 'eventId' => "Done!"
]); ]);
break; break;
......
...@@ -174,30 +174,29 @@ class LogsController ...@@ -174,30 +174,29 @@ class LogsController
'%REMOTE_IP%' '%REMOTE_IP%'
], ],
[ [
$args['lineData']['tableName'] ?? '', $args['lineData']['tableName'] ?? ':noTableName',
$args['lineData']['recordId'] ?? '', $args['lineData']['recordId'] ?? ':noRecordId',
$args['lineData']['eventType'] ?? '', $args['lineData']['eventType'] ?? ':noEventType',
$GLOBALS['login'] ?? '', $GLOBALS['login'] ?? ':noUser',
$args['lineData']['eventId'] ?? '', $args['lineData']['eventId'] ?? ':noEventId',
$args['lineData']['moduleId'] ?? '', $args['lineData']['moduleId'] ?? ':noModuleId',
$_SERVER['REMOTE_ADDR'] ?? '' $_SERVER['REMOTE_ADDR'] ?? gethostbyname(gethostname())
], ],
"[%WHERE%][%ID%][%HOW%][%USER%][%WHAT%][%ID_MODULE%][%REMOTE_IP%]" "[%WHERE%][%ID%][%HOW%][%USER%][%WHAT%][%ID_MODULE%][%REMOTE_IP%]"
); );
if (!empty($args['lineData']['isSql'])) { if (!empty($args['lineData']['isSql'])) {
$logLine = empty($args['lineData']['sqlQuery']) ? '[]' : "[" . $args['lineData']['sqlQuery'] . "]"; $logLine = empty($args['lineData']['sqlQuery']) ? '[:noSqlQuery]' : "[" . $args['lineData']['sqlQuery'] . "]";
if (empty($args['lineData']['sqlData'])) { if (empty($args['lineData']['sqlData'])) {
$logLine .= "[]"; $logLine .= "[:noSqlData]";
} elseif (is_array($args['lineData']['sqlData'])) { } elseif (is_array($args['lineData']['sqlData'])) {
$logLine .= "[" . json_encode($args['lineData']['sqlData']) . "]"; $logLine .= "[" . json_encode($args['lineData']['sqlData']) . "]";
} else { } else {
$logLine .= "[" . $args['lineData']['sqlData'] . "]"; $logLine .= "[" . $args['lineData']['sqlData'] . "]";
} }
$logLine .= empty($args['lineData']['sqlException']) ? '[]' : "[" . $args['lineData']['sqlException'] . "]"; $logLine .= empty($args['lineData']['sqlException']) ? '[:noSqlException]' : "[" . $args['lineData']['sqlException'] . "]";
} }
$logLine = TextFormatModel::htmlWasher($logLine); $logLine = TextFormatModel::htmlWasher($logLine);
$logLine = TextFormatModel::removeAccent(['string' => $logLine]); $logLine = TextFormatModel::removeAccent(['string' => $logLine]);
$logLine = str_replace('[]', '', $logLine);
return $logLine; return $logLine;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment