TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Advanced PHP Programming (http://www.talkphp.com/advanced-php-programming/)
-   -   "Singleton" Error Queue? (http://www.talkphp.com/advanced-php-programming/2186-singleton-error-queue.html)

RobertK 02-04-2008 06:15 PM

"Singleton" Error Queue?
 
I was working and thinking, as per usual, and figured it might be a handy thing to implement a type that acted as a singleton where I could put a bunch of non-fatal errors into. This way I can have a stack of debug messages and handle them however I want, without try/except. This is for things like query errors, object initialization faults, and the like. Obviously in a finished product the last thing you want is a die statement triggering, and a client wondering how to get back.

Any suggestions for how I could set an object such as this up? Or should I even use an object? I just came up with this recently, so I figured I'd get input on this.

Salathe 02-04-2008 06:50 PM

You could expand it into, in a general sense, a log/debug type of object which stores (optionally different levels if you like) messages, debug data, 'errors', etc. You could use it with the set_exception/error_handler functions if you headed more along the errors route.

RobertK 02-04-2008 06:55 PM

I could do the exception handlers, but for things like malformed queries I think that's a bit much. But I also don't know that I want an array of messages stored in the database object itself either. I think I want a little separation there, but I'm not sure how to handle it with a singleton/registry style access method.

xenon 02-04-2008 07:17 PM

Perhaps you could try extending the Exception class.

RobertK 02-04-2008 07:21 PM

I could. Though then I'd have to have an error container, override the exception handler and such. Is that better than just making a sort of custom logger?

xenon 02-05-2008 01:15 AM

1 Attachment(s)
Look what I found. I wrote some time ago some sort of logger (for fun, to be honest). You can use it if you find it useful.

RobertK 02-05-2008 01:54 AM

That looks helpful, thanks Xenon. I'll let you know if I use it.


All times are GMT. The time now is 04:04 PM.

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