ActiveTable/Debugging
From ActivePHP
ActiveTable has the capability to output a ton of useful debugging information, using either PEAR::Log or just printing to the user's screen. Two attributes control logging, debug and logfile_path:
[edit] Use
To have it log to a file:
class Foo extends ActiveTable { protected $table_name = 'foo'; protected $primary_key = 'foo_id'; protected $debug = true; // Defaults to false protected $logfile_path = '/tmp/active_table.log'; // This is the default value } // end Foo class
To have your log messages outputted to the screen, set logfile_path to null.
[edit] Logged Events
- Every SQL query executed is logged.
- The execution time for every query executed is logged.
- The total execution time for (most) methods is logged, along with the fact that they were called.
[edit] Extending
The method #debug(mixed $message[,string $type]) is called to perform logging. Redefining this method to do something else is the easiest way to change the global logging behavior.
class My_ActiveTable extends ActiveTable { protected $debug = true; protected function debug($message,$type='info') { send_email('admin@yourdomain.com',"[$type] ActiveTable Debug Event!",$message); } // end debug } // end My_ActiveTable class Foo extends My_ActiveTable { protected $table_name = 'foo'; protected $primary_key = 'foo_id'; } // end Foo class
