59 Logger::getInstance()->addLogger($this);
70 if (!isset($instance)) {
72 $instance =
new $class();
96 $this->activated =
false;
109 error_reporting(E_ALL | E_STRICT);
111 $this->activated =
true;
116 $this->
debugbar =
new StandardDebugBar();
117 $this->renderer = $this->
debugbar->getJavascriptRenderer();
120 $this->
debugbar->addCollector(
new MessagesCollector(
'Deprecated'));
121 $this->
debugbar->addCollector(
new MessagesCollector(
'Blocks'));
122 $this->
debugbar->addCollector(
new MessagesCollector(
'Extra'));
126 $debugStack =
$xoops->db()->getConfiguration()->getSQLLogger();
127 $this->
debugbar->addCollector(
new DebugBar\Bridge\DoctrineCollector($debugStack));
151 $this->quietmode =
true;
161 static $addedResource =
false;
163 if ($this->activated && !$addedResource) {
167 $this->renderer->setIncludeVendors(
true);
168 $this->renderer->setEnableJqueryNoConflict(
false);
169 list($cssAssets, $jsAssets) = $this->renderer->getAssets();
178 '/vendor/font-awesome/',
183 $cssAssets = array_filter(
185 function ($filename) use ($excludes) {
186 foreach ($excludes as $exclude) {
187 if (
false !== strpos($filename, $exclude)) {
195 $jsAssets = array_filter(
197 function ($filename) use ($excludes) {
198 foreach ($excludes as $exclude) {
199 if (
false !== strpos($filename, $exclude)) {
206 $cssAssets[] =
'modules/debugbar/assets/css/font-awesome.css';
209 $xoops->theme()->addStylesheetAssets($cssAssets,
'cssembed,?cssmin');
210 $xoops->theme()->addScriptAssets($jsAssets,
'?jsmin');
212 $addedResource =
true;
227 if ($this->activated) {
230 }
catch (Exception $e) {
247 if ($this->activated) {
250 }
catch (Exception $e) {
268 if ($this->activated) {
269 $level = LogLevel::INFO;
271 $level = LogLevel::ERROR;
274 'channel'=>
'Queries',
277 'query_time'=>$query_time
279 $this->
log($level,
$sql, $context);
294 if ($this->activated) {
295 $context = array(
'channel'=>
'Blocks',
'cached'=>$cached,
'cachetime'=>$cachetime);
296 $this->
log(LogLevel::INFO,
$name, $context);
310 if ($this->activated) {
311 $context = array(
'channel'=>
'Extra',
'name'=>
$name);
312 $this->
log(LogLevel::INFO,
$msg, $context);
325 if ($this->activated) {
339 if ($this->activated) {
340 $this->
debugbar[
'exceptions']->addException($e);
351 if ($this->activated) {
354 foreach ($data as $k => $v) {
356 $data[$k] =
'(empty string)';
357 } elseif ($v === null) {
359 } elseif ($v ===
true) {
360 $data[$k] =
'bool TRUE';
361 } elseif ($v ===
false) {
362 $data[$k] =
'bool FALSE';
365 ksort($data, SORT_NATURAL | SORT_FLAG_CASE);
367 new DebugBar\DataCollector\ConfigCollector($data,
'Smarty')
381 $this->
log(LogLevel::DEBUG,
$var);
391 if ($this->activated) {
393 $this->activated=
false;
394 $this->renderingEnabled =
false;
408 $this->renderingEnabled =
true;
420 if (!$this->activated) {
425 $head =
'</script>'.$this->renderer->renderHead().
'<script>';
426 $xoops->theme()->addScript(null, null, $head);
428 $log = $this->renderer->render();
429 $this->renderingEnabled = $this->activated =
false;
431 $pattern =
'<!--{xo-logger-output}-->';
432 $pos = strpos($output, $pattern);
433 if ($pos !==
false) {
434 return substr($output, 0, $pos) . $log . substr($output, $pos + strlen($pattern));
436 return $output . $log;
445 if ($this->activated) {
448 if (!empty($queue)) {
449 foreach ($queue as $q) {
450 $this->
debugbar[
'time']->addMeasure($q[
'label'], $q[
'start'], $q[
'start'] + $q[
'elapsed']);
456 if (
false === $this->quietmode) {
457 if (isset(
$_SERVER[
'HTTP_X_REQUESTED_WITH'])
458 &&
$_SERVER[
'HTTP_X_REQUESTED_WITH'] ==
'XMLHttpRequest') {
460 $log = $this->renderer->render(
false);
462 $log = $this->renderer->render();
466 $this->
debugbar->sendDataInHeaders();
479 public function emergency($message, array $context = array())
481 if ($this->activated) {
482 $this->
log(LogLevel::EMERGENCY, $message, $context);
497 public function alert($message, array $context = array())
499 if ($this->activated) {
500 $this->
log(LogLevel::ALERT, $message, $context);
514 public function critical($message, array $context = array())
516 if ($this->activated) {
517 $this->
log(LogLevel::CRITICAL, $message, $context);
530 public function error($message, array $context = array())
532 if ($this->activated) {
533 $this->
log(LogLevel::ERROR, $message, $context);
548 public function warning($message, array $context = array())
550 if ($this->activated) {
563 public function notice($message, array $context = array())
565 if ($this->activated) {
566 $this->
log(LogLevel::NOTICE, $message, $context);
580 public function info($message, array $context = array())
582 if ($this->activated) {
583 $this->
log(LogLevel::INFO, $message, $context);
595 public function debug($message, array $context = array())
597 if ($this->activated) {
598 $this->
log(LogLevel::DEBUG, $message, $context);
611 public function log($level, $message, array $context = array())
613 if (!$this->activated) {
617 $channel =
'messages';
624 if (isset($context[
'channel'])) {
625 $chan = strtolower($context[
'channel']);
629 $msg = $message .
': ';
630 if ($context[
'cached']) {
637 $channel =
'Deprecated';
642 $msg = $context[
'name'] .
': ' . $message;
645 $channel =
'Queries';
647 $qt = empty($context[
'query_time']) ?
648 '' : sprintf(
'%0.6f - ', $context[
'query_time']);
649 if ($level == LogLevel::ERROR) {
653 $msg .=
' -- Error number: '
654 . (is_scalar($context[
'errno']) ? $context[
'errno'] :
'?')
656 . (is_scalar($context[
'error']) ? $context[
'error'] :
'?');
663 case LogLevel::EMERGENCY:
666 case LogLevel::ALERT:
669 case LogLevel::CRITICAL:
672 case LogLevel::ERROR:
678 case LogLevel::NOTICE:
684 case LogLevel::DEBUG:
if(empty($settings['ROOT_PATH'])) elseif(empty($settings['DB_PARAMETERS'])) $error
error($message, array $context=array())
critical($message, array $context=array())
const _MD_DEBUGBAR_PHP_VERSION
emergency($message, array $context=array())
const _MD_DEBUGBAR_CACHED
const _MD_DEBUGBAR_NOT_CACHED
warning($message, array $context=array())
notice($message, array $context=array())
addQuery($sql, $error=null, $errno=null, $query_time=null)
alert($message, array $context=array())
debug($message, array $context=array())
startTime($name= 'XOOPS', $label=null)
if(!is_object($module)||!$module->getVar('isactive')) $msg
static dumpQueuedTimers($returnOnly=false)
const _MD_DEBUGBAR_INCLUDED_FILES
log($level, $message, array $context=array())
addBlock($name, $cached=false, $cachetime=0)
info($message, array $context=array())