celsowm
celsowm

Reputation: 404

What is the best way to implement a log in every method executed in PHP?

I have dozens of Classes with a unique ParentClass, i need implements a way to create a log each time any method is executed !

Have a way to do this only in the ParentClass or something like?

thanks, Celso

Upvotes: 1

Views: 345

Answers (3)

Ernestas Stankevičius
Ernestas Stankevičius

Reputation: 2493

You can try backtrace, but its hard to implament. And some information here.

Upvotes: 1

Alfwed
Alfwed

Reputation: 3282

Why would you want to do that?

If you want to see the execution plan you can :

  1. run a xdebug profiling
  2. run your application in a debugger

If it's for something else, don't do it. It will only make your code harder to read and fill your HDs with useless data that you can have whenever you want using points 1) ou 2) described above.

Edit : my company does exactly what you want and I assure you you don't want to get there.

Upvotes: 0

cypher
cypher

Reputation: 6992

There is a way for protected & private methods, however AFAIK none to log public method calls.

Upvotes: 0

Related Questions