Do Procedure On Function Call

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Jonnycake
Forum Newbie
Posts: 7
Joined: Sun Mar 23, 2014 6:49 am

Do Procedure On Function Call

Post 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 :).
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Do Procedure On Function Call

Post by requinix »

Not really, no.
Jonnycake
Forum Newbie
Posts: 7
Joined: Sun Mar 23, 2014 6:49 am

Re: Do Procedure On Function Call

Post 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 :).
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Do Procedure On Function Call

Post by Christopher »

You should follow the standard Logger PSR spec. There are a number of good logging class, like Analog. Then logging is injectable.
(#10850)
Jonnycake
Forum Newbie
Posts: 7
Joined: Sun Mar 23, 2014 6:49 am

Re: Do Procedure On Function Call

Post by Jonnycake »

@Christopher Thanks for the suggestion, I'll check it out :)
Post Reply