From 169820ae437e7318041b889f6e1bae8cd676217e Mon Sep 17 00:00:00 2001 From: sparkyx Date: Fri, 24 Oct 2025 11:51:25 +0200 Subject: [PATCH] Improve record_log() : use noalyss/log and apache log --- include/ajax/ajax_action_remove_concerned.php | 2 +- include/ajax/ajax_add_concerned_card.php | 4 ++-- include/ajax/ajax_add_menu.php | 2 +- include/ajax/ajax_admin.php | 8 ++++---- include/ajax/ajax_anc_key_choice.php | 4 ++-- include/ajax/ajax_anc_key_clean.php | 4 ++-- include/ajax/ajax_anc_key_compute.php | 2 +- include/ajax/ajax_display_submenu.php | 4 ++-- include/ajax/ajax_ledger.php | 2 +- include/ajax/ajax_remove_submenu.php | 4 ++-- include/ajax/ajax_template_cat_category.php | 4 ++-- include/class/action_document_type_mtable.class.php | 2 +- include/class/document_export.class.php | 4 ++-- include/class/lettering.class.php | 2 +- include/export/export_balance_pdf.php | 4 ++-- include/export/export_ledger_csv.php | 2 +- include/export/export_ledger_pdf.php | 2 +- include/export/export_security_pdf.php | 2 +- include/lib/ac_common.php | 4 ++-- include/periode.inc.php | 3 ++- include/recover.php | 2 +- unit-test/include/class/acc_computeTest.php | 2 +- 22 files changed, 35 insertions(+), 34 deletions(-) diff --git a/include/ajax/ajax_action_remove_concerned.php b/include/ajax/ajax_action_remove_concerned.php index 93362b2d6..3ad682dcf 100644 --- a/include/ajax/ajax_action_remove_concerned.php +++ b/include/ajax/ajax_action_remove_concerned.php @@ -33,7 +33,7 @@ try catch (Exception $exc) { echo $exc->getMessage(); - error_log($exc->getTraceAsString()); + record_log($exc); return; } /* diff --git a/include/ajax/ajax_add_concerned_card.php b/include/ajax/ajax_add_concerned_card.php index 7cc903e95..e509e322c 100644 --- a/include/ajax/ajax_add_concerned_card.php +++ b/include/ajax/ajax_add_concerned_card.php @@ -38,7 +38,7 @@ try catch (Exception $exc) { echo $exc->getMessage(); - error_log($exc->getTraceAsString()); + record_log($exc); return; } /* @@ -152,4 +152,4 @@ echo <<$html EOF; -?> \ No newline at end of file +?> diff --git a/include/ajax/ajax_add_menu.php b/include/ajax/ajax_add_menu.php index 66b13ccfb..72c61f684 100644 --- a/include/ajax/ajax_add_menu.php +++ b/include/ajax/ajax_add_menu.php @@ -51,7 +51,7 @@ try catch (Exception $exc) { echo $exc->getMessage(); - error_log($exc->getTraceAsString()); + record_log($exc); return; } diff --git a/include/ajax/ajax_admin.php b/include/ajax/ajax_admin.php index 20a19494d..79238c20e 100644 --- a/include/ajax/ajax_admin.php +++ b/include/ajax/ajax_admin.php @@ -68,7 +68,7 @@ if ($op=='folder_add') // operation } catch (Exception $exc) { - error_log($exc->getTraceAsString()); + record_log($exc); $content=_('Erreur paramètre'); $status="NOK"; return; @@ -104,7 +104,7 @@ if ($op=='folder_remove') // operation } catch (Exception $exc) { - error_log($exc->getTraceAsString()); + record_log($exc); $content=_('Erreur paramètre'); $status="NOK"; } @@ -166,7 +166,7 @@ if ($op=='folder_display') // operation } catch (Exception $exc) { - error_log($exc->getTraceAsString()); + record_log($exc); $content=_('Erreur paramètre'); $status="NOK"; } @@ -200,7 +200,7 @@ if (in_array($op, array('modele_drop', 'modele_modify', 'folder_modify', 'folder } catch (Exception $exc) { - error_log($exc->getTraceAsString()); + record_log($exc); $content=_('Erreur paramètre'); $status="NOK"; //---------------------------------------------------------------- diff --git a/include/ajax/ajax_anc_key_choice.php b/include/ajax/ajax_anc_key_choice.php index ba58f7659..f048733af 100644 --- a/include/ajax/ajax_anc_key_choice.php +++ b/include/ajax/ajax_anc_key_choice.php @@ -38,7 +38,7 @@ try } catch (Exception $exc) { - error_log($exc->getTraceAsString()); + record_log($exc); return; } @@ -60,4 +60,4 @@ echo <<$html EOF; -?> \ No newline at end of file +?> diff --git a/include/ajax/ajax_anc_key_clean.php b/include/ajax/ajax_anc_key_clean.php index 40b9bde0e..e190dee28 100644 --- a/include/ajax/ajax_anc_key_clean.php +++ b/include/ajax/ajax_anc_key_clean.php @@ -39,7 +39,7 @@ try } catch (Exception $exc) { - error_log($exc->getTraceAsString()); + record_log($exc); return; } @@ -71,4 +71,4 @@ echo <<$html EOF; -?> \ No newline at end of file +?> diff --git a/include/ajax/ajax_anc_key_compute.php b/include/ajax/ajax_anc_key_compute.php index eba0547ae..2c0984318 100644 --- a/include/ajax/ajax_anc_key_compute.php +++ b/include/ajax/ajax_anc_key_compute.php @@ -43,7 +43,7 @@ try catch (Exception $exc) { echo $exc->getMessage(); - error_log($exc->getTraceAsString()); + record_log($exc); return; } ob_start(); diff --git a/include/ajax/ajax_display_submenu.php b/include/ajax/ajax_display_submenu.php index 7713ccb81..efb7bf3bf 100644 --- a/include/ajax/ajax_display_submenu.php +++ b/include/ajax/ajax_display_submenu.php @@ -43,7 +43,7 @@ try } catch (Exception $exc) { - error_log($exc->getTraceAsString()); + record_log($exc); return; } @@ -52,4 +52,4 @@ $profile=new Profile_Menu($cn); $profile->p_id=$p_id; $profile->display_module_menu($module,$p_level); -?> \ No newline at end of file +?> diff --git a/include/ajax/ajax_ledger.php b/include/ajax/ajax_ledger.php index 3c81249d9..5b367c23f 100644 --- a/include/ajax/ajax_ledger.php +++ b/include/ajax/ajax_ledger.php @@ -46,7 +46,7 @@ try { $gDossier = dossier::id(); } catch (Exception $exc) { - error_log($exc->getTraceAsString()); + record_log($exc); return; } diff --git a/include/ajax/ajax_remove_submenu.php b/include/ajax/ajax_remove_submenu.php index 9a147b520..61e6c2d21 100644 --- a/include/ajax/ajax_remove_submenu.php +++ b/include/ajax/ajax_remove_submenu.php @@ -37,7 +37,7 @@ try } catch (Exception $exc) { - error_log($exc->getTraceAsString()); + record_log($exc); return; } @@ -48,4 +48,4 @@ $cn->exec_sql('delete from profile_menu where pm_id = $1 or pm_id_dep=$1',array( $cn->exec_sql("delete from profile_menu " . " where pm_id_dep is not null " . " and pm_id_dep not in (select pm_id from profile_menu)"); -?> \ No newline at end of file +?> diff --git a/include/ajax/ajax_template_cat_category.php b/include/ajax/ajax_template_cat_category.php index a94e787a7..0c740024e 100644 --- a/include/ajax/ajax_template_cat_category.php +++ b/include/ajax/ajax_template_cat_category.php @@ -79,7 +79,7 @@ switch ($action) catch (Exception $exc) { echo $exc->getMessage(); - error_log($exc->getTraceAsString()); + record_log($exc); $answer['message']=$exc->getMessage(); } @@ -107,7 +107,7 @@ switch ($action) catch (Exception $exc) { echo $exc->getMessage(); - error_log($exc->getTraceAsString()); + record_log($exc); $answer['message']=$exc->getMessage(); } break; diff --git a/include/class/action_document_type_mtable.class.php b/include/class/action_document_type_mtable.class.php index b6b4f7b99..37f335307 100644 --- a/include/class/action_document_type_mtable.class.php +++ b/include/class/action_document_type_mtable.class.php @@ -229,7 +229,7 @@ class Action_Document_Type_MTable extends Manage_Table_SQL $cn->rollback(); echo $exc->getMessage(); - error_log($exc->getTraceAsString()); + record_log($exc); } } diff --git a/include/class/document_export.class.php b/include/class/document_export.class.php index 12f76719c..e31f0273c 100644 --- a/include/class/document_export.class.php +++ b/include/class/document_export.class.php @@ -91,7 +91,7 @@ class Document_Export $zip=new Zip_Extended(); $res=$zip->open("{$this->store_pdf}/result.zip",ZipArchive::CREATE); if ($res !== true) { - error_log("ERR-DE89 cannot create zip file"); + record_log("ERR-DE89 cannot create zip file"); record_log($this); throw new Exception ("ERR-DE89 cannot recreate zip"); } @@ -99,7 +99,7 @@ class Document_Export // addGmpn $res=$zip->add_file_pattern($this->store_pdf,"/.*pdf/"); if ($res == 0) { - error_log("ERR-DE96 aucun fichier trouvé"); + record_log("ERR-DE96 aucun fichier trouvé"); record_log($this); throw new Exception ( "ERR-DE96 cannot recreate zip"); } diff --git a/include/class/lettering.class.php b/include/class/lettering.class.php index 7306c50c3..194b1ddde 100644 --- a/include/class/lettering.class.php +++ b/include/class/lettering.class.php @@ -310,7 +310,7 @@ class Lettering catch (Exception $exc) { echo $exc->getMessage(); - error_log($exc->getTraceAsString()); + record_log($exc); $this->db->rollback(); return; } diff --git a/include/export/export_balance_pdf.php b/include/export/export_balance_pdf.php index 6e3f342a9..31e1620c1 100644 --- a/include/export/export_balance_pdf.php +++ b/include/export/export_balance_pdf.php @@ -49,8 +49,8 @@ try { $to_poste = $http->request("to_poste"); $p_filter = $http->request("p_filter", "string"); } catch (Exception $exc) { - error_log("Missing parameters"); - error_log($exc->getTraceAsString()); + record_log("Missing parameters"); + record_log($exc); return; } diff --git a/include/export/export_ledger_csv.php b/include/export/export_ledger_csv.php index a09b15618..5e63e20cb 100644 --- a/include/export/export_ledger_csv.php +++ b/include/export/export_ledger_csv.php @@ -56,7 +56,7 @@ try catch (Exception $exc) { echo $exc->getMessage(); - error_log($exc->getTraceAsString()); + record_log($exc); throw $exc; } diff --git a/include/export/export_ledger_pdf.php b/include/export/export_ledger_pdf.php index 972e861db..9866594c4 100644 --- a/include/export/export_ledger_pdf.php +++ b/include/export/export_ledger_pdf.php @@ -44,7 +44,7 @@ try catch (Exception $exc) { echo $exc->getMessage(); - error_log($exc->getTraceAsString()); + record_log($exc); throw $exc; } $l_type = "JRN"; diff --git a/include/export/export_security_pdf.php b/include/export/export_security_pdf.php index e7058e5df..807cc1731 100755 --- a/include/export/export_security_pdf.php +++ b/include/export/export_security_pdf.php @@ -33,7 +33,7 @@ try } catch (Exception $exc) { - error_log($exc->getTraceAsString()); + record_log($exc); return; } diff --git a/include/lib/ac_common.php b/include/lib/ac_common.php index 891fb7f11..09b1b730c 100644 --- a/include/lib/ac_common.php +++ b/include/lib/ac_common.php @@ -170,7 +170,7 @@ function echo_error($p_log, $p_line="", $p_message="") { $msg="ERREUR :" . $p_log . " " . $p_line . " " . $p_message; echo $msg; - syslog(LOG_ERR,$msg); + record_log($msg); } @@ -1893,4 +1893,4 @@ function find_idx($array,$key,$value) { } } return -1; -} \ No newline at end of file +} diff --git a/include/periode.inc.php b/include/periode.inc.php index 5fa81d638..26b3ca78d 100644 --- a/include/periode.inc.php +++ b/include/periode.inc.php @@ -80,7 +80,7 @@ if ( isset($_POST['mod_exercice_label_bt'])) { catch (Exception $exc) { echo_warning( $exc->getMessage()); - error_log($exc->getTraceAsString()); + record_log($exc); $cn->rollback(); } @@ -109,6 +109,7 @@ if (isset($_POST['add_exercice'])) catch (Exception $ex) { echo_warning($ex->getMessage()); + record_log($exc); } } //------------------------------------------------------------------- diff --git a/include/recover.php b/include/recover.php index 901697341..b64918eb1 100644 --- a/include/recover.php +++ b/include/recover.php @@ -90,7 +90,7 @@ elseif ($action=="send_email") : $user_password=$exist_request[0]['password']; /* if too many request , there is a bug somewhere , so record an warning */ if ( count($exist_request)> 1 ){ - error_log("WRE109 Trop de request pour ".var_export($exist_request,true)); + record_log("WRE109 Trop de request pour ".var_export($exist_request,true)); } } diff --git a/unit-test/include/class/acc_computeTest.php b/unit-test/include/class/acc_computeTest.php index 4abf4dc0f..1ec8c18df 100644 --- a/unit-test/include/class/acc_computeTest.php +++ b/unit-test/include/class/acc_computeTest.php @@ -224,7 +224,7 @@ class Acc_ComputeTest extends TestCase catch (Exception $exc) { echo $exc->getMessage(); - error_log($exc->getTraceAsString()); + record_log($exc->getTraceAsString()); $this->assertTrue(FALSE); }