8
0

can add customized debug messages

Dieser Commit ist enthalten in:
Daniel Seifert 2022-08-03 00:32:09 +02:00
Ursprung 210920cfaa
Commit 4cea1658bb
Signiert von: DanielS
GPG-Schlüssel-ID: 6A513E13AEE66170
3 geänderte Dateien mit 36 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -141,6 +141,14 @@ class DebugBarComponent extends BaseController
$property->setValue($this->debugBar, $collectors);
}
/**
* @return StandardDebugBar
*/
public function getDebugBar(): StandardDebugBar
{
return $this->debugBar;
}
/**
* @return JavascriptRenderer
*/

Datei anzeigen

@ -50,7 +50,7 @@ class ShopControl_DebugBar extends ShopControl_DebugBar_parent
{
if (!isAdmin()) {
/** @var DebugBarComponent $debugBarComponent */
$activeView = Registry::getConfig()->getActiveView();
$activeView = Registry::getConfig()->getTopActiveView();
if ($activeView &&
$debugBarComponent = $activeView->getComponent(DebugBarComponent::class)
) {

Datei anzeigen

@ -13,7 +13,10 @@
declare(strict_types=1);
use D3\DebugBar\Application\Component\DebugBarComponent;
use D3\DebugBar\Application\Models\TimeDataCollectorHandler;
use DebugBar\DataCollector\MessagesCollector;
use OxidEsales\Eshop\Core\Registry;
function startProfile($sProfileName)
{
@ -56,4 +59,28 @@ function stopProfile($sProfileName)
}
$executionCounts[$sProfileName]++;
$aStartTimes[$sProfileName] = microtime(true);
}
function debugVar($mVar, $blToFile = false)
{
if ($blToFile) {
$out = var_export($mVar, true);
$f = fopen(Registry::getConfig()->getConfigParam('sCompileDir') . "/vardump.txt", "a");
fwrite($f, $out);
fclose($f);
} else {
if (!isAdmin()) {
$activeView = Registry::getConfig()->getTopActiveView();
/** @var DebugBarComponent $debugBarComponent */
$debugBarComponent = $activeView->getComponent(DebugBarComponent::class);
/** @var MessagesCollector $messages */
$messages = $debugBarComponent->getDebugBar()->getCollector('messages');
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
//$location = $trace[1]['class'] . '::' . $trace[1]['function']. '(' . $trace[0]['line'] . ')';
$location = $trace[1]['class'] . '::' . $trace[1]['function'];
$messages->addMessage($mVar, $location);
} else {
dumpVar($mVar, $blToFile);
}
}
}