mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-24 10:21:32 +01:00
Fix error when using a log hangler that make output into the http
header. We must add a log before any generation of ouput content so we are sure a buffering of output has been started.
This commit is contained in:
@@ -559,16 +559,17 @@ function dol_strtoupper($utf8_string)
|
||||
* This function works only if syslog module is enabled.
|
||||
* This must not use any call to other function calling dol_syslog (avoid infinite loop).
|
||||
*
|
||||
* @param string $message Line to log. Ne doit pas etre traduit si level = LOG_ERR
|
||||
* @param int $level Log level
|
||||
* 0=Show nothing
|
||||
* 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_INFO=6, LOG_DEBUG=7
|
||||
* @param int $ident 1=Increase ident of 1, -1=Decrease ident of 1
|
||||
* @param string $suffixinfilename When output is a file, append this suffix into default log filename.
|
||||
* @param string $message Line to log.
|
||||
* @param int $level Log level
|
||||
* 0=Show nothing
|
||||
* 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_INFO=6, LOG_DEBUG=7
|
||||
* @param int $ident 1=Increase ident of 1, -1=Decrease ident of 1
|
||||
* @param string $suffixinfilename When output is a file, append this suffix into default log filename.
|
||||
* @param string $restricttologhandler Output log only for this log handler
|
||||
* @return void
|
||||
*/
|
||||
function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename='')
|
||||
function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename='', $restricttologhandler='')
|
||||
{
|
||||
global $conf, $user;
|
||||
|
||||
@@ -591,7 +592,7 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename='
|
||||
$conf->logbuffer[] = dol_print_date(time(),"%Y-%m-%d %H:%M:%S")." ".$message;
|
||||
}
|
||||
|
||||
//TODO: Remove this. MAIN_ENABLE_LOG_HTML should be deprecated and use a HTML handler
|
||||
//TODO: Remove this. MAIN_ENABLE_LOG_HTML should be deprecated and use a log handler dedicated to HTML output
|
||||
// If enable html log tag enabled and url parameter log defined, we show output log on HTML comments
|
||||
if (! empty($conf->global->MAIN_ENABLE_LOG_HTML) && ! empty($_GET["log"]))
|
||||
{
|
||||
@@ -615,10 +616,10 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename='
|
||||
else if (! empty($_SERVER['COMPUTERNAME'])) $data['ip'] = $_SERVER['COMPUTERNAME'].(empty($_SERVER['USERNAME'])?'':'@'.$_SERVER['USERNAME']);
|
||||
// This is when PHP session is ran outside a web server, like from Linux command line (Not always defined, but usefull if OS defined it).
|
||||
else if (! empty($_SERVER['LOGNAME'])) $data['ip'] = '???@'.$_SERVER['LOGNAME'];
|
||||
|
||||
// Loop on each log handler and send output
|
||||
foreach ($conf->loghandlers as $loghandlerinstance)
|
||||
{
|
||||
if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) continue;
|
||||
$loghandlerinstance->export($data,$suffixinfilename);
|
||||
}
|
||||
unset($data);
|
||||
|
||||
Reference in New Issue
Block a user