Skip to content

Conversation

@elkuku
Copy link
Contributor

@elkuku elkuku commented May 12, 2018

This is a redo of #15472

Summary of Changes

The goal of this PR is to refactor the debug plugin (currently more than 2.000 lines of code) into smaller pieces.
An external library is used to display a floating debug bar. See a demo

Testing Instructions

Run

composer install
npm i

Turn on debug and/or language debug and play with the various options in plugin configuration.

Expected result

A beautiful floating debug toolbar (mobile ready) 😉

bildschirmfoto_2018-05-12_16-19-09

Actual result

A not so beautiful looong thingy, fixed to the very bottom of the page.

bildschirmfoto_2018-05-12_16-20-57

Documentation Changes Required

Alot 👅

Extended Description

While working on a Symfony project, I was amazed by the debug bar they offer and I thought about the old Joomla! plugin...

Integrating the Symfony bar would require a lot of dependencies from Symfony, probably including the Symfony Application class. While this would be amazing, I suspect that this is not gonna happen any time soon...

So I started playing with maximebf/debugbar which claims to be inspired by the Symfony debug bar, but for "non Symfony" projects ;)

This resulted in some DataCollector classes which, apart from collecting data, are responsible for bringing the collected data to something "serializable".

This data is then serialized and written to disk for later analysis. (Not implemented yet)

After a thousand words, here are some screens:
Note: Since the "old" code is still in place, you will see the "old" output as well as the "new " output in the screenshots.


Session

2017-04-18-121246_1366x768_scrot


Profile

2017-04-21-133031_1366x768_scrot


Queries

The database query tab features including
* Highlighted queries
* Timings and memory reports
* A (clickable) call stack with indication of the "caller" (somewhat experimental)
* Duplicated query check
* Duplicated queries can be filtered Note the filter buttons are at the lower right corner 😉
* A button to "copy" the query to the clipboard

bildschirmfoto_2018-09-02_12-34-16

Call stack
joomla 4 debug bar -call-stack

Duplicates filter
menus items main menu joomla 4 debug bar administration

Explains
bildschirmfoto_2018-09-04_11-39-58


Deprecation logging

2017-04-21-171552_1366x768_scrot
bildschirmfoto_2018-05-12_16-37-52


Language stuff

Should look as before, just more readable and compact.

Loaded

bildschirmfoto_2018-09-02_11-08-43

Untranslated

bildschirmfoto_2018-09-02_11-09-44

Errors

bildschirmfoto_2018-09-02_11-10-42


Mobile ready

screenshot_20170426-010917

Tested on a 5'' screen with fat fingers and it worked pretty well.


Happy debugging =;)

P.S.: @todo Things that should be added (later)

  • Memory display on profile tab - Thanks @Hackwar
  • A lot of visual improvements to be implemented using modern CSS technioques - Thanks @all

PLG_DEBUG_FIELD_LOG_CATEGORY_MODE_EXCLUDE="Exclude"
PLG_DEBUG_FIELD_LOG_CATEGORY_MODE_INCLUDE="Include"
PLG_DEBUG_FIELD_LOG_CATEGORY_MODE_LABEL="Log Category Mode"
PLG_DEBUG_FIELD_LOG_DEPRECATED_CORE_DESC="Only relevant for Joomla! core developers"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we dont need this string, just remove it please.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 😉

@laoneo
Copy link
Member

laoneo commented May 14, 2018

Does the query tab has duplicate query detection and can show the stack trace? That's two very useful features of the current debug plugin.

@mbabker
Copy link
Contributor

mbabker commented May 14, 2018

Yes it can highlight duplicate queries. I don't remember off hand if the debug bar natively supports collecting stack traces, but the Laravel package that extends this does have them so even if it's not a native capability it can be added in.

@mbabker
Copy link
Contributor

mbabker commented May 14, 2018

Actually, we couldn't use the existing database integrations in the main debug bar package anyway. That one only supports PDO, we have non-PDO drivers in our database API (MySQLi and SQL Server).

@elkuku
Copy link
Contributor Author

elkuku commented May 14, 2018

Does the query tab has duplicate query detection and can show the stack trace? That's two very useful features of the current debug plugin.

Currently only the executed queries are displayed in a custom tab. For the reasons Michael stated we can not use the provided db tab so... - no stack trace, timings, memory etc.
I'd like to propose adding a component that displays additional information like this - in the next PR 😉

YES 😉

@ggppdk
Copy link
Contributor

ggppdk commented Jul 15, 2018

@elkuku

hi, will this PR have solution for issue:
#21131

@brianteeman
Copy link
Contributor

@ggppdk why don't you test it and see

@ggppdk
Copy link
Contributor

ggppdk commented Jul 15, 2018

Ok , will find time to test this, regardless of including solution for #21131

@Hackwar
Copy link
Member

Hackwar commented Jul 16, 2018

Applying this to the current 4.0-dev branch fails on several levels. @elkuku can you fix the conflicts here?

@elkuku
Copy link
Contributor Author

elkuku commented Sep 2, 2018

@Hackwar

what I'm missing is the used memory of the different parts in the Profile tab. Can you have a look there?

I think we can at least display the amount (using numbers) would this be helpful?

the queries are not easy to read for me

I've changed the color of the separator line to a beautiful blue and added some padding - what do you think/see?

bildschirmfoto_2018-09-02_12-34-16

Maybe we can color the icons/buttons/action areas of each query in the Joomla colors?

That sounds like a nice idea but I'm afraid that if I perform this task it will look horrible - trust me 👅

@infograf768

Here color instead of Loaded/Not Loaded (not good for colour blind people). Maybe using both would be better.

I've added a + or a - sign accordingly - WDYT?

Alsdo no need imho to repeat the name of the file with these 2 columns.

The first column is supposed to be the "extension" that is trying to load the language file(s) - Note the first line joomla is loading the xx-XX.ini file 😉 I've also added a header to make this clearer. I believe this is nice for "grouping" the files.

if I remember well, some time ago, it would show nearby the en-GB equivalent file as loaded instead.

Actually I noticed the same thing. As you can see in my screenshot this is different in admin and site...

bildschirmfoto_2018-09-02_11-08-43

Here constants are not displayed fully.

So instead of waiting for #21457 being merged, I changed (J)Language here in this PR and also added the full stack trace.

bildschirmfoto_2018-09-02_11-09-44

@laoneo
Copy link
Member

laoneo commented Sep 3, 2018

I had a look on your pr and some parts are missing according to your description. For example the duplicates query or the call stack of a query.

@elkuku
Copy link
Contributor Author

elkuku commented Sep 3, 2018

@laoneo

some parts are missing according to your description. For example the duplicates query or the call stack of a query.

I made the query traces optional to avoid performance problems on "large" sites. so please make sure that you enabled them in plugin options.

plugins system debug j4 debugbar administration

Note: The "Query Types" option is currently not functional

As for the duplicated queries, that should work as announced - what output do you get / expect?

@elkuku
Copy link
Contributor Author

elkuku commented Sep 4, 2018

@Hackwar
I've updated the profiler tab to include memory marks - Could you check please?
bildschirmfoto_2018-09-04_08-21-30

@elkuku
Copy link
Contributor Author

elkuku commented Sep 4, 2018

Just a small update for possible testers... Support for query explains has been added.
bildschirmfoto_2018-09-04_11-39-58

@laoneo
Copy link
Member

laoneo commented Sep 6, 2018

Can we get one more test and then I would suggest we merge it and do finalize the other issues in their own pr's.

@roland-d
Copy link
Contributor

roland-d commented Sep 8, 2018

@elkuku Great, great work. Well done.
@laoneo Here is my second test again. The things is awesome works great.

I have some ideas for enhancements but let's do that in a new issues.

@ghost
Copy link

ghost commented Sep 8, 2018

Ready to Commit after required one more test.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Sep 8, 2018
@laoneo laoneo merged commit 4f50668 into joomla:4.0-dev Sep 10, 2018
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Sep 10, 2018
@laoneo
Copy link
Member

laoneo commented Sep 10, 2018

Thank you very much for this nice change!

@laoneo laoneo added this to the Joomla 4.0 milestone Sep 10, 2018
@laoneo laoneo added the Feature label Sep 10, 2018
@roland-d
Copy link
Contributor

Very happy to see this go in. +1 for progress.

@elkuku elkuku deleted the debug-bar-2 branch September 10, 2018 14:29
@elkuku
Copy link
Contributor Author

elkuku commented Sep 10, 2018

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.