php - Clean stack trace for logs -


i have several classes (a, b, c , on) extends abstract class called mother. "sons" use method "save":

<?php  class mother {     public function save() {         echo "mother saves!\n";         debug_print_backtrace();     } }  class extends mother {     public function save() {         echo "calling save a\n";         parent::save();     } }  $test = new a; $test->save();  ?> 

if run code, result of debug_print_backtrace clean , need:

#0 mother->save() called @ [/home/xfiddlec/public_html/main/code_44364601.php:13] #1 a->save() called @ [/home/xfiddlec/public_html/main/code_44364601.php:18] 

the problem is, if using framework (im using zend2), stack trace on 1mb, huge string. if there way can limit trace coverage? application having file, line , name of class extended mother enough.

if understand question right answer simple. throw , catch exception

try{     throw new exception(); }catch( exception $e ){     echo $e->gettraceasstring(); } 

it's neat trick use debugging. can trace array , use slice or whatnot on it.


Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -