diff --git a/htdocs/admin/debugbar.php b/htdocs/admin/debugbar.php index 34cc06c5f08..16dd39b7085 100644 --- a/htdocs/admin/debugbar.php +++ b/htdocs/admin/debugbar.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2005-2019 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2007 Rodolphe Quiedeville * Copyright (C) 2013 Juanjo Menent diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 3468a75aece..f59cd82da3e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -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."
\n"; + //$debugbar['log']->addMessage($logline, 'ERR', false); + }*/ + + print ''."\n"; + print $debugbar->getRenderer()->render(); + } + elseif (count($conf->logbuffer)) // If there is some logs in buffer to show { print "\n"; print "