Knowledgebase:Framework Debugging
Usage
Note: (This applies to all Contrexx versions since version 2.1 SP3)
The Contrexx debug class DBG provides two simple methods to control the debug mode of the system. These are DBG::activate() and DBG::deactivate(). You can activate/deactivate the several debug levels everywhere in the code and as often as you need to. Simply pass one or more of the available debug levels (listed below) to these methods.
Examples: <highlightsyntax> // activate PHP Error Reporting DBG::activate(DBG_PHP); </highlightsyntax> <highlightsyntax> // deactivate PHP Error Reporting DBG::deactivate(DBG_PHP); </highlightsyntax>
You can also activate/deactivate several levels in one step by passing them as in a bitwise join operation. <highlightsyntax>// this will activate the PHP Error Reporting, showing the database queries and logging everything via FirePHP. DBG::activate(DBG_PHP | DBG_ADODB | DBG_LOG_FIREPHP);
// this will deactivate all the activated levels from above again DBG::deactivate(DBG_PHP | DBG_ADODB | DBG_LOG_FIREPHP);
// the above statements are the equivalent to these statements:
DBG::activate(DBG_PHP);
DBG::activate(DBG_ADODB);
DBG::activate(DBG_LOG_FIREPHP);
DBG::deactivate(DBG_PHP); DBG::deactivate(DBG_ADODB); DBG::deactivate(DBG_LOG_FIREPHP); </highlightsyntax>
Debug Levels
Option | Description |
---|---|
DBG_PHP | show PHP errors/warnings/notices |
DBG_ADODB | show ADODB queries |
DBG_ADODB_TRACE | show ADODB queries with backtrace |
DBG_ADODB_ERROR | show ADODB queriy errors only |
DBG_LOG_FILE | DBG: log to file (dbg.log). this will either log to /dbg.log, /cadmin/dbg.log or /update/dbg.log depending on which part of the system you're using |
DBG_LOG_FIREPHP | DBG: log via FirePHP. FirePHP is an extension to Firebug |
Debugging with older Contrexx versions
Before version 2.1 SP3, you have to set the constant _DEBUG to one of the above mentioned debug levels. (The code is located at the beginning of the file index.php)
There are also the two special debug levels DBG_NONE and DBG_ALL which cause to either deactivate the debug mode at all or activate all of its levels.
Example: <highlightsyntax>define('_DEBUG', DBG_PHP); DBG::__internal__setup(); </highlightsyntax> This will activate the PHP Error Reporting.