[Vtigercrm-developers] Debugging class

J Zakhar john at tantor.com
Fri Feb 16 12:14:18 PST 2007


I as some may know, am writing custom modules for vtiger. I needed a way 
to debug, an easy way not involving print.. or Zend so I composed this 
class,


<?php

class logger
{
    private $_Obj = null;

    function __construct( $object )
    {
        assert( is_object( $object ) );
        $this->_Obj = $object;
   
    }
   
    function __call( $func, $args )
    {
        if ( method_exists( $this->_Obj, $func) ) {
            echo( "$func( ".join( ",", $args )." )\n<br>" );
            call_user_func_array( array( $this->_Obj, $func ), $args );
        } else {
            print "(magic) __call: func=$func args=$args (UNDEFINED 
METHOD)\n";
        }
    }


}


?>

you call it like this


<?php

$d = new logger( new class_you_want_to_debug() );
?>

hope some of you find it useful =)



More information about the vtigercrm-developers mailing list