John Schlick - 2012-10-02

Welcome to the Debug_Object

A relatively simple class to help you instrument your codebase for debugging while the code is being written as well as long after. Simple to write code for, Simple to turn on.

Debugging code has always been a tricky prospect. Most people use one of two methods: Either include "log" statements to see whats going on while running a routine,
and then either delete them, or comment them out when they are done,
(For legacy code, the commenting it out mechanism is often used so that the code is left to uncomment the next time that piece of code is worked on)
or you can rely on a "debugger" to trace whats going on, and then look thru the more copious output.
PHP does not really HAVE a good debugger, so most PHP developers are left to write output statements.
Remembering WHERE those debug statements are so your log files don't fill up can also be a pain.

The Debug_Object class is a "take" on instrumenting your code but it's output can be easily turned on and off for any section of your code.
This way you write the debug code you want, and leave it in your codebase, but the object knows when to execute that code, so it generates ONLY the output that you want based on what you are working on.

I find it very useful for working on code I wrote a while ago since all I have to do is turn on debug for the part of the code I'm working on, and I'm very quickly up to speed without having to rewrite all the debug code.

Note: The Debug_Object currently supports echoing output to the screen or to the error_log. If there are enough requests I will expand the output mechanisms to include the firePHP project

There are two parts to using the Debug_Object. Instrumenting the code, and turning it on.

Instrumenting the code.

[Instrumenting The Code]

Turning it on:

[Turning It On]

The Debug_Timer

[Debug Timer]

 

Related

Wiki: Debug Timer
Wiki: Instrumenting The Code
Wiki: Turning It On


Last edit: John Schlick 2012-10-05