More data into log

This commit is contained in:
Laurent Destailleur 2023-03-30 14:48:04 +02:00
parent 5cf1ed058f
commit 53d530f126
2 changed files with 12 additions and 5 deletions

View File

@ -849,7 +849,7 @@ class CMailFile
dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR);
if (!empty($conf->global->MAIN_MAIL_DEBUG)) {
$this->save_dump_mail_in_err();
$this->save_dump_mail_in_err('Mail with topic '.$this->subject);
}
} else {
dol_syslog("CMailFile::sendfile: mail end success", LOG_DEBUG);
@ -1030,7 +1030,7 @@ class CMailFile
$res = false;
if (!empty($conf->global->MAIN_MAIL_DEBUG)) {
$this->save_dump_mail_in_err();
$this->save_dump_mail_in_err('Mail with topic '.$this->subject);
}
}
}
@ -1170,7 +1170,7 @@ class CMailFile
$res = false;
if (!empty($conf->global->MAIN_MAIL_DEBUG)) {
$this->save_dump_mail_in_err();
$this->save_dump_mail_in_err('Mail with topic '.$this->subject);
}
} else {
dol_syslog("CMailFile::sendfile: mail end success", LOG_DEBUG);
@ -1281,13 +1281,20 @@ class CMailFile
* Save content if mail is in error
* Used for debugging.
*
* @param string $message Add also a message
* @return void
*/
public function save_dump_mail_in_err()
public function save_dump_mail_in_err($message = '')
{
global $dolibarr_main_data_root;
if (@is_writeable($dolibarr_main_data_root)) { // Avoid fatal error on fopen with open_basedir
// Add message to dolibarr_mail.log
if ($message) {
dol_syslog($message, LOG_DEBUG, 0, '_mail');
}
// Move dolibarr_mail.log into a dolibarr_mail.err or dolibarr_mail.date.err
$srcfile = $dolibarr_main_data_root."/dolibarr_mail.log";
if (getDolGlobalString('MAIN_MAIL_DEBUG_ERR_WITH_DATE')) {
$destfile = $dolibarr_main_data_root."/dolibarr_mail.".dol_print_date(dol_now(), 'dayhourlog', 'gmt').".err";

View File

@ -1661,7 +1661,7 @@ function dol_ucwords($string, $encoding = "UTF-8")
* On Windows LOG_ERR=4, LOG_WARNING=5, LOG_NOTICE=LOG_INFO=6, LOG_DEBUG=6 si define_syslog_variables ou PHP 5.3+, 7 si dolibarr
* On Linux LOG_ERR=3, LOG_WARNING=4, LOG_NOTICE=5, LOG_INFO=6, LOG_DEBUG=7
* @param int $ident 1=Increase ident of 1 (after log), -1=Decrease ident of 1 (before log)
* @param string $suffixinfilename When output is a file, append this suffix into default log filename.
* @param string $suffixinfilename When output is a file, append this suffix into default log filename. Example '_stripe', '_mail'
* @param string $restricttologhandler Force output of log only to this log handler
* @param array|null $logcontext If defined, an array with extra informations (can be used by some log handlers)
* @return void