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:
parent
b8ed553365
commit
73266bb965
@ -559,16 +559,17 @@ function dol_strtoupper($utf8_string)
|
|||||||
* This function works only if syslog module is enabled.
|
* This function works only if syslog module is enabled.
|
||||||
* This must not use any call to other function calling dol_syslog (avoid infinite loop).
|
* 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 string $message Line to log.
|
||||||
* @param int $level Log level
|
* @param int $level Log level
|
||||||
* 0=Show nothing
|
* 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 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
|
* 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 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 $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
|
* @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;
|
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;
|
$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 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"]))
|
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']);
|
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).
|
// 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'];
|
else if (! empty($_SERVER['LOGNAME'])) $data['ip'] = '???@'.$_SERVER['LOGNAME'];
|
||||||
|
|
||||||
// Loop on each log handler and send output
|
// Loop on each log handler and send output
|
||||||
foreach ($conf->loghandlers as $loghandlerinstance)
|
foreach ($conf->loghandlers as $loghandlerinstance)
|
||||||
{
|
{
|
||||||
|
if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) continue;
|
||||||
$loghandlerinstance->export($data,$suffixinfilename);
|
$loghandlerinstance->export($data,$suffixinfilename);
|
||||||
}
|
}
|
||||||
unset($data);
|
unset($data);
|
||||||
|
|||||||
@ -7,6 +7,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/syslog/logHandler.php';
|
|||||||
*/
|
*/
|
||||||
class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface
|
class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface
|
||||||
{
|
{
|
||||||
|
var $code = 'chromephp';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return name of logger
|
* Return name of logger
|
||||||
*
|
*
|
||||||
@ -111,7 +113,7 @@ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output log content
|
* Output log content. We also start output buffering at first log write.
|
||||||
*
|
*
|
||||||
* @param array $content Content to log
|
* @param array $content Content to log
|
||||||
* @return void
|
* @return void
|
||||||
|
|||||||
@ -7,6 +7,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/syslog/logHandler.php';
|
|||||||
*/
|
*/
|
||||||
class mod_syslog_file extends LogHandler implements LogHandlerInterface
|
class mod_syslog_file extends LogHandler implements LogHandlerInterface
|
||||||
{
|
{
|
||||||
|
var $code = 'file';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return name of logger
|
* Return name of logger
|
||||||
|
|||||||
@ -7,6 +7,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/syslog/logHandler.php';
|
|||||||
*/
|
*/
|
||||||
class mod_syslog_firephp extends LogHandler implements LogHandlerInterface
|
class mod_syslog_firephp extends LogHandler implements LogHandlerInterface
|
||||||
{
|
{
|
||||||
|
var $code = 'firephp';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return name of logger
|
* Return name of logger
|
||||||
*
|
*
|
||||||
|
|||||||
@ -7,6 +7,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/syslog/logHandler.php';
|
|||||||
*/
|
*/
|
||||||
class mod_syslog_syslog extends LogHandler implements LogHandlerInterface
|
class mod_syslog_syslog extends LogHandler implements LogHandlerInterface
|
||||||
{
|
{
|
||||||
|
var $code = 'syslog';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return name of logger
|
* Return name of logger
|
||||||
*
|
*
|
||||||
|
|||||||
@ -490,7 +490,8 @@ if (! defined('NOLOGIN'))
|
|||||||
if (! $login || (in_array('ldap',$authmode) && empty($passwordtotest))) // With LDAP we refused empty password because some LDAP are "opened" for anonymous access so connexion is a success.
|
if (! $login || (in_array('ldap',$authmode) && empty($passwordtotest))) // With LDAP we refused empty password because some LDAP are "opened" for anonymous access so connexion is a success.
|
||||||
{
|
{
|
||||||
// We show login page
|
// We show login page
|
||||||
dol_loginfunction($langs,$conf,(! empty($mysoc)?$mysoc:''));
|
dol_syslog("--- Access to ".$_SERVER["PHP_SELF"]." showing the login form and exit");
|
||||||
|
dol_loginfunction($langs,$conf,(! empty($mysoc)?$mysoc:''));
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user