开发者

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

开发者 https://www.devze.com 2023-04-04 00:44 出处:网络
I have dozens of Classes w开发者_运维知识库ith a unique ParentClass, i need implements a way to create a log each time any method is executed !

I have dozens of Classes w开发者_运维知识库ith 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


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


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消