2
0
forked from Wavyzz/dolibarr

Enhance the module debugbar. Do not scan the log anymore.

This commit is contained in:
Laurent Destailleur
2019-03-23 14:37:54 +01:00
parent 05c2ae6778
commit df9e121ac6
7 changed files with 65 additions and 241 deletions

View File

@@ -982,7 +982,7 @@ function dol_strtoupper($utf8_string)
*/
function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = '', $restricttologhandler = '')
{
global $conf, $user;
global $conf, $user, $debugbar;
// If syslog module enabled
if (empty($conf->syslog->enabled)) return;
@@ -998,8 +998,8 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename =
if (! empty($message))
{
// Test log level
$logLevels = array(LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING, LOG_NOTICE, LOG_INFO, LOG_DEBUG);
if (!in_array($level, $logLevels, true))
$logLevels = array(LOG_EMERG=>'EMERG', LOG_ALERT=>'ALERT', LOG_CRIT=>'CRITICAL', LOG_ERR=>'ERR', LOG_WARNING=>'WARN', LOG_NOTICE=>'NOTICE', LOG_INFO=>'INFO', LOG_DEBUG=>'DEBUG');
if (! array_key_exists($level, $logLevels))
{
throw new Exception('Incorrect log level');
}
@@ -1008,9 +1008,10 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename =
$message = preg_replace('/password=\'[^\']*\'/', 'password=\'hidden\'', $message); // protection to avoid to have value of password in log
// If adding log inside HTML page is required
if (! empty($_REQUEST['logtohtml']) && (! empty($conf->global->MAIN_ENABLE_LOG_TO_HTML) || ! empty($conf->global->MAIN_LOGTOHTML))) // MAIN_LOGTOHTML kept for backward compatibility
if ((! empty($_REQUEST['logtohtml']) && ! empty($conf->global->MAIN_ENABLE_LOG_TO_HTML))
|| (! empty($user->rights->debugbar->read) && is_object($debugbar)))
{
$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")." ".$logLevels[$level]." ".$message;
}
//TODO: Remove this. MAIN_ENABLE_LOG_INLINE_HTML should be deprecated and use a log handler dedicated to HTML output
@@ -7164,7 +7165,7 @@ function complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type,
*/
function printCommonFooter($zone = 'private')
{
global $conf, $hookmanager, $user;
global $conf, $hookmanager, $user, $debugbar;
global $action;
global $micro_start_time;
@@ -7328,11 +7329,24 @@ function printCommonFooter($zone = 'private')
// Add Xdebug coverage of code
if (defined('XDEBUGCOVERAGE'))
{
print_r(xdebug_get_code_coverage());
print_r(xdebug_get_code_coverage());
}
// If there is some logs in buffer to show
if (count($conf->logbuffer))
// Add DebugBar data
if (! empty($user->rights->debugbar->read) && is_object($debugbar))
{
$debugbar['time']->stopMeasure('pageaftermaster');
/*foreach($conf->logbuffer as $logline)
{
//print $logline."<br>\n";
//$debugbar['log']->addMessage($logline, 'ERR', false);
}*/
print '<!-- Output debugbar data -->'."\n";
print $debugbar->getRenderer()->render();
}
elseif (count($conf->logbuffer)) // If there is some logs in buffer to show
{
print "\n";
print "<!-- Start of log output\n";