• Welcome to Simple Machines Community Forum. Please login or sign up.
January 25, 2022, 07:33:53 AM

News:

Want to get involved in developing SMF, then why not lend a hand on our github!


DevCenter

Started by NanoSector, December 18, 2012, 03:05:26 AM

Previous topic - Next topic

NanoSector

December 18, 2012, 03:05:26 AM Last Edit: December 11, 2014, 10:17:29 AM by NanoSector
Link to Mod

DevCenter
If you need to report a bug, please do so on GitHub!

This modification adds a couple of settings to the admin panel that might be useful when developing a modification. Along with that it also is able to monitor the server load. It is able to:

  • Show the amount of error log entries, right in the Admin menu button;
  • Show debugging information without having to edit your Settings.php;
  • Trigger phpinfo() by going to index.php?action=phpinfo
  • Monitor server load in the footer.

Languages:
- English

Installation:
Install through the package manager.

Files modified:
- Sources/ManageErrors.php
- Themes/default/index.template.php
- Sources/Subs.php

Changelog
v0.4.1
! Fixed bug with the Admin error log counter (thanks phantomm!)

v0.4
+ Add server load indicator (for Windows only, thanks Gryzor for the suggestion & testing!)
+ Add Spanish translation (thanks davidhs!)
- Removed Dutch translation (will get to that at a later time)

v0.3.2
- Removed server load checking since it's built in to SMF itself
! Code cleanup

v0.3.1
! Fixed undefined index upon install (thanks phantomm for reporting and thanks Arantor for bringing me on the right track)

v0.3
! Rewrote the counting mechanism of the error log entries (thanks Arantor!)
! Bug fixes

v0.2
+ Added Dutch translation

v0.1
- Initial release

License:
This mod is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.

Tips and tricks

  • Show the time taken to execute a query in bold:
QuoteIn Sources/Subs.php, find:
if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at']))
echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br />';
elseif (isset($qq['t']))
echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br />';


Replace with:
if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at']))
echo '<strong>' . sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '</strong><br />';
elseif (isset($qq['t']))
echo '<strong>' . sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '</strong><br />';
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Gryzor

Well, this could be useful indeed, but why not add a server load indicator? Perhaps next to the Admin menu, just like the errors number?

Thanks!

NanoSector

Quite possible, I'll look into adding it in a future version. Thanks :)
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Gryzor

At first I was actually looking for a special section showing the load, until I looked at the description more closely and understood the scope.

Heck, it'd be fantastic (maybe another mod...) if the admin could have a small box sitting at a corner providing server stats - cpu, mem, db hits, stuff like that. I wonder how come nobody has thought of that before :D

Anyhow, thanks for the mod, it's neat!

NanoSector

If you want to have such a mod I can look in creating one that provides the functionality for you. :)
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Gryzor

I think lots of people would be interested in it... very convenient, in place of opening a console window to keep track of things.

Other possibilities: response times (from an external service of course), uptime, FS size (or maybe just forum dir size)...

Arantor

The one thing that bothers me about this, just as I found when writing my own version of this ages ago -  http://custom.simplemachines.org/mods/index.php?mod=2441 - is that you're still adding a query per page that the admin is browsing, even though if the error log is MyISAM, it's quite a cheap query.

What you might want to do is expand things such that if an error is logged, add it to a central count of errors.
No good deed goes unpunished
All helpful urges should be circumvented

NanoSector

Quote from: Arantor on January 04, 2013, 01:45:23 PM
The one thing that bothers me about this, just as I found when writing my own version of this ages ago -  http://custom.simplemachines.org/mods/index.php?mod=2441 - is that you're still adding a query per page that the admin is browsing, even though if the error log is MyISAM, it's quite a cheap query.

What you might want to do is expand things such that if an error is logged, add it to a central count of errors.
I actually tore this package apart and submitted it as an external package and the Cust. team at that time rejected it because it found your package better written :)

Thanks for your suggestion, do you think storing the count in $modSettings and updating that variable whenever an error is logged is a good idea?

I should definitely rewrite this one time because I wrote this a while ago and haven't updated it since.
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Arantor

Well, essentially yes. ;)

The tricks are: up front, start a counter of 0, then as an error occurs, add 1 to the count, and then before obexit is called, update $modSettings. Then, when you do go to the error log, validate whether the number is different, and if it is, update $modSettings because then you have an empirical source to play with.
No good deed goes unpunished
All helpful urges should be circumvented

NanoSector

Quote from: Arantor on January 04, 2013, 01:52:41 PM
Well, essentially yes. ;)

The tricks are: up front, start a counter of 0, then as an error occurs, add 1 to the count, and then before obexit is called, update $modSettings.
Okay, but can't I create an install script that gets the count at the time of installing the mod? Not that people can't just visit the Error Log panel but I'd like to have stuff in order right when installing :)

QuoteThen, when you do go to the error log, validate whether the number is different, and if it is, update $modSettings because then you have an empirical source to play with.
This is a good plan, though what variable should I be looking for when in the Error Log panel?

I'm not too familar with SMFs error logging system, sorry :)
Thank you :)
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Arantor

QuoteOkay, but can't I create an install script that gets the count at the time of installing the mod? Not that people can't just visit the Error Log panel but I'd like to have stuff in order right when installing

Missing the point. Start the counter of 0 at the start of the *page*, then only update the counter if there actually have been errors.

You can additionally update it when first installing, sure.
No good deed goes unpunished
All helpful urges should be circumvented

NanoSector

Quote from: Arantor on January 04, 2013, 02:02:23 PM
QuoteOkay, but can't I create an install script that gets the count at the time of installing the mod? Not that people can't just visit the Error Log panel but I'd like to have stuff in order right when installing

Missing the point. Start the counter of 0 at the start of the *page*, then only update the counter if there actually have been errors.

You can additionally update it when first installing, sure.
Ah wait I see, you mean that I should gather how many errors occured on the current page, and add that to the $modSettings variable just before quitting? That's a bloody good idea, actually, thanks :)
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Arantor

Yup, that's what I mean.

* Arantor is not being entirely theoretical here.
No good deed goes unpunished
All helpful urges should be circumvented

NanoSector

I've updated the mod, thanks very much Arantor :)
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Shambles

Other than "adds a couple of settings to the admin panel.." what does this mod actually do? And what is DevCenter? A search of DevCenter doesn't show anything other than this mod  ???

Scuse my ignorance in this matter...

Arantor

DevCenter is the name of the mod, nothing more... it is a few things given to developers in an attempt to help them out.

Firstly, it adds a page where PHP info can be seen, action=phpinfo to show that helpful page. Fortunately, Zend has finally fixed phpinfo's underlying function not to be an XSS vulnerability, which is nice.

Secondly, it adds an option to show the current load of the host, useful to use the load balancing options. But that's only really an option if you're on a system that has load balancing enabled and usable and most people for whom that applies, well, they are probably using a VPS or similar where they can get that information themselves without little extra effort (e.g. using `top` in a shell)

Lastly, it adds the ability to show the number of errors in the error log, but does so in the admin menu itself, so you'll know just by browsing your forum how many errors there are. That one is useful, though I'd note that there are other mods that allow you to get that without any extra stuff as linked earlier (you might recognise the handiwork of mod 2441's author :D)
No good deed goes unpunished
All helpful urges should be circumvented

NanoSector

Quote from: ®Shambles on January 05, 2013, 09:42:25 AM
Other than "adds a couple of settings to the admin panel.." what does this mod actually do? And what is DevCenter? A search of DevCenter doesn't show anything other than this mod  ???

Scuse my ignorance in this matter...
I added a few screenshots, hope it gets clearer now :)

Thanks for explaining Arantor, that's exactly what the mod does (or, is supposed to do, rather ;))
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Shambles

I appreciate the time you spent creating that summary, I really do.

Maybe those details could form part of the mod's description, as now I can see it being beneficial to more than just developers.

The authorship of mod 2441 had not passed me by, as it happens... ;)


ETA: [above was for the member known as Arantor]
ETAA: [additional info from the member known as Yoshi2889 is also appreciated]

NanoSector

Quote from: ®Shambles on January 05, 2013, 09:55:29 AM
I appreciate the time you spent creating that summary, I really do.

Maybe those details could form part of the mod's description, as now I can see it being beneficial to more than just developers.
Yes, I was lazy at the time of writing the description :P I'll update it straight away, thanks for letting me know it's vague.
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Arantor

I'd argue that making phpinfo open to any user is a security risk, however trivial. What I'd be inclined to do is move it to a page in the admin panel somewhere and possibly even enforce allowedTo('admin_forum') first.
No good deed goes unpunished
All helpful urges should be circumvented

Advertisement: