Get content of Tracy panel (Nextras\Dbal query panel) to plane text

TonnyVlcek
Member | 31
+
0
-

Hey,
I'm currently developing a REST API and I really miss Tracy panel.

In this specific situation I wanted to see the queries executed by Nextras ORM. I can usually find this information in the Tracy Nextras\Dbal query panel. I looked into it and found out that the queries are being logged to the panel class using Nextras\Dbal\Bridges\NetteTracy\ConnectionPanel::logQuery() however the property is private so that I can't retrieve this information without a custom getter:

/* Get the SQL strings of executed queries */
public function getQueries()
{
	return array_column($this->queries, 1);
}

If I could access the queries property then I could do something like this and print the queries to the page or log them to a file (Debugger:log())

Debugger::getBar()->getPanel(ConnectionPanel::class)->getQueries()

(This solution actually works but I find it rather ugly even for the debugging purposes).

Is there something that I'm missing and this can be in fact done in a way that is ‘clean’?

CZechBoY
Member | 3608
+
0
-

You can enable tracybar by outputting html. I usually make switch in output method so I can see dumped json and tracy bar.

if (Debugger::isDebugMode() && $showHtml) {
    Debugger::dump($output);
} else {
    sendJson($output)
}
TonnyVlcek
Member | 31
+
0
-

CZechBoY wrote:

You can enable tracybar by outputting html. I usually make switch in output method so I can see dumped json and tracy bar.

if (Debugger::isDebugMode() && $showHtml) {
    Debugger::dump($output);
} else {
    sendJson($output)
}

Alright, that worked.
My setup is such that in BaseApiPresenter::beforeRender() I'm sending payload automatically. But when I now need to dump something I can just override the beforeRender() method in the presenter where I need to dump and then the json is not sent but I get my dump result and my Tracy bar.
It's not exactly what I was looking for but it gets the job done for the time being.
Thanks for the tip :)