TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Advanced PHP Programming (http://www.talkphp.com/advanced-php-programming/)
-   -   Debugging Class in creation of a Framework (http://www.talkphp.com/advanced-php-programming/4131-debugging-class-creation-framework.html)

Orc 04-13-2009 03:06 AM

Debugging Class in creation of a Framework
 
Hi, I'm going into the creation / design of a framework and the first thing I'd like to know about is what a debugging class is. :-P

Kalle 04-13-2009 02:16 PM

A debugging class would be a component of the framework that eases the debugging if something goes wrong while executing. An example of a debugging component could be to generate a backtrace using debug_backtrace() into some easily understandable trace, so errors/warnings/exceptions can be tracked and you can figure out where you went wrong.

Tanax 04-13-2009 04:35 PM

On this subject - how would you go an create an Error class for a framework, and how would you implement it and use it?

Salathe 04-13-2009 05:48 PM

Create an Error class for a framework? I'm not entirely sure that you would want to do so.

Tanax 04-13-2009 09:20 PM

Why wouldn't you want to create an errorclass that handles Exceptions and stuff ?

Salathe 04-13-2009 09:23 PM

Firstly, error conditions and exceptions are different beasts. Secondly, you probably wouldn't want one class to take care of everything, but rather tie a collection of classes together: these will be different depending on your framework and requirements wanted.

Tanax 04-13-2009 10:10 PM

Well, isn't Exceptions a form of Error Handling - yes?
I didn't specify Error conditions, I just said Errorclass.

But okay, I see.. well, but still does anyone know a tutorial or anything about how to create a "collection of classes" to handle exceptions? Sure - it may be different than the framework I use, but I'm just looking for some guidance to understand the concept. I know how Exceptions work, I just need to understand how an Exception class works ^_^

Orc 04-14-2009 04:03 AM

Quote:

Originally Posted by Kalle (Post 23053)
A debugging class would be a component of the framework that eases the debugging if something goes wrong while executing. An example of a debugging component could be to generate a backtrace using debug_backtrace() into some easily understandable trace, so errors/warnings/exceptions can be tracked and you can figure out where you went wrong.

Would this work with error_get_last?

Kalle 04-14-2009 01:24 PM

Quote:

Originally Posted by Orc (Post 23074)
Would this work with error_get_last?

error_get_last() or register your own error handlers (set_error_handler & set_exception_handler) which pops all the errors onto a stack and then list all registered errors upon debugging shutdown.

Orc 04-15-2009 12:11 AM

Quote:

Originally Posted by Kalle (Post 23080)
error_get_last() or register your own error handlers (set_error_handler & set_exception_handler) which pops all the errors onto a stack and then list all registered errors upon debugging shutdown.

How should I create a debugging class? That's all I'm wondering now.

Kalle 04-15-2009 02:07 AM

I would rather use a set of procedural functions for debugging than a class, instead of making a class where almost all methods are better served static (from my point of view).

All you need is a set of functions thats usable for debugging, and only included when debug mode is triggered (if your system ofcourse have a debugging mode).

Example of functions can be:
  • Backtracing in a nice manner thats more detailed that the regular debug_print_backtrace() output
  • Functions for catching and displaying exceptions and errors in somewhat unified interface, combining this with the backtrace is a good idea, as it can show if anywhere in the backtrace something occured
  • Assertions, http://www.php.net/assert


All times are GMT. The time now is 01:54 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0