Page 1 of 1

Do Procedure On Function Call

Posted: Sun Mar 23, 2014 7:05 am
by Jonnycake
Okay, so I'm in the midst of creating a PHP framework, a project which started out as a simple template system I've now been working on for a year and a half to two years due to a couple computer crashes and ideas for new features and implementations for those features by that annoying kid in my head :roll: . Anyways, point being, I want to be able to produce debug messages without manually adding:

Code: Select all

if($_GET['debug']==1) echo "Dbg: Some debug message here...";
to each and every function I want to debug.

Is there a function in PHP that allows you to do that everytime I call a function within a certain class? I know about magic methods (like __call), but that's not exactly what I want being that it's only executed when the function does not exist.

Any help would be appreciated, thanks :).

Re: Do Procedure On Function Call

Posted: Sun Mar 23, 2014 7:45 am
by requinix
Not really, no.

Re: Do Procedure On Function Call

Posted: Sun Mar 23, 2014 7:54 am
by Jonnycake
Alright, I figured that because I couldn't find anything on google about it, but thank you anyways, looks like I'll be doing that when I start learning about creating extensions. Thanks for the quick reply :).

Re: Do Procedure On Function Call

Posted: Sun Mar 23, 2014 11:45 am
by Christopher
You should follow the standard Logger PSR spec. There are a number of good logging class, like Analog. Then logging is injectable.

Re: Do Procedure On Function Call

Posted: Mon Mar 24, 2014 5:53 am
by Jonnycake
@Christopher Thanks for the suggestion, I'll check it out :)