Topic: HOWTO: Enable DEBUG mode

When DEBUG is enabled, PunBB will display

- more detailed error messages if/when something goes wrong.
- script generation time in the footer.
- no. of queries executed in the footer.


Enable DEBUG by opening up include/common.php, finding (line 26)

//define('PUN_DEBUG', 1);

And removing the two slashes so that it looks like this:

define('PUN_DEBUG', 1);

"Programming is like sex: one mistake and you have to support it for the rest of your life."

2

Re: HOWTO: Enable DEBUG mode

Rickard,

It might be a better idea to suggest adding the line to config.php. For example, I have a local development copy of my PunBB board (because I'm modifying it) and the remote working copy. If PUN_DEBUG is included in common.php then I would (potentially) have to change that file every time I upload a new version to the server.

Re: HOWTO: Enable DEBUG mode

but you only enable it when you hit a problem...

Re: HOWTO: Enable DEBUG mode

rain: The idea is that people generally shouldn't have it enabled. People think it's cool to show off how many milliseconds the page was generated in, but they don't realize debug mode will also reveal things about their server they might not want to disclose in the event of a failure.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

5

Re: HOWTO: Enable DEBUG mode

Fair enough. Your style is different than mine, that's ok;)

6 (edited by TomTester 2004-12-07 22:55)

Re: HOWTO: Enable DEBUG mode

Why not just MOD the footer to see just the milliseconds info without enabling Pun Debug mode?  Would that not solve the safety issue.

Changes /footer.php in the punbb root (do save a backup first PLEASE!)

Look for:

// Display debug info (if enabled/defined)
if (defined('PUN_DEBUG'))
{
    // Calculate script generation time
    list($usec, $sec) = explode(' ', microtime());
    $time_diff = sprintf('%.3f', ((float)$usec + (float)$sec) - $pun_start);

    echo "\t\t\t\t\t\t".'<br>[ <span class="punclosed">Generated in '.$time_diff.' seconds, '.$db->get_num_queries().' queries executed</span> ]'."\n";
}

Change to:

// Display debug info (if enabled/defined)
// if (defined('PUN_DEBUG'))
// {
    // Calculate script generation time
    list($usec, $sec) = explode(' ', microtime());
    $time_diff = sprintf('%.3f', ((float)$usec + (float)$sec) - $pun_start);

    echo "\t\t\t\t\t\t".'<br>[ <span class="punclosed">Generated in '.$time_diff.' seconds, '.$db->get_num_queries().' queries executed</span> ]'."\n";
// }

In text: I've commented out (using '//') the check for debug mode... if you have your backup, you could also just remove the commented lines in the replacement code.

Re: HOWTO: Enable DEBUG mode

Because the generation time really isn't interesting other than when debugging/developing.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

8

Re: HOWTO: Enable DEBUG mode

Because the generation time really isn't interesting other than when debugging/developing.

Oh well, if it amuses some people to show off speed (which I have to agree is not too interesting), then that's fine.

GET ON THE TELEPHONE!!

9

Re: HOWTO: Enable DEBUG mode

anyway / any mod to have this done at admin panel?

Re: HOWTO: Enable DEBUG mode

Nope: there really isn't a need to switch it on/off enough to warrant a mod (plus, the mod couldn't rely on the database to store its information)

Re: HOWTO: Enable DEBUG mode

af3 wrote:

anyway / any mod to have this done at admin panel?

Thing is, we only really need debug mode when there's a problem and if it's enabled via the admin interface and we, for some reason, can't access the admin interface, we're screwed.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: HOWTO: Enable DEBUG mode

Looks neat to have it on; what's the downside to showing a few statistics about your server?

Check Maid maid service

Re: HOWTO: Enable DEBUG mode

When you run into an error, people can see the query that gives the error.

14

Re: HOWTO: Enable DEBUG mode

Should we fix for every edition of PunBB?

Re: HOWTO: Enable DEBUG mode

anyway / any mod to have this done at admin panel?                                      Sexless marriage