Is debug_backtrace() safe for serious usage in production environment?

前端 未结 3 496
情话喂你
情话喂你 2021-01-21 01:41

It\'s functionality is so strong that I worry about its stability and performance.

What do you think?

UPDATE

What I\'m doing is this:

3条回答
  •  温柔的废话
    2021-01-21 02:16

    debug_backtrace is relatively expensive in my experience, so you should be careful it is not used in loops (e.g. in a custom error handler that catches warnings or notices and performs a backtrace every time).

    For any kind of error logging, I think it's pretty invaluable, and because it's going to be called only once, definitely not a performance problem. It is surely always good to include a backtrace in an error report.

    I can't see why there would be any specific issues with this function's stability (i.e. calling it causing another crash), I've never heard of any problems. The only "gotcha" I can see is this note in the User Contributed Notes when using objects as function parameters that have no _toString method defined.

    Of course, you should never output the results of a backtrace to the end user - that goes without saying.

提交回复
热议问题