Development Debugging
Contents
Usage
Since Contrexx version 2.2 SP6 you can activate the debugging output of Contrexx through the Development tools tab in the Global Configuration section (Administration > Global Configuration > Development tools).
Activating the debugging output through the Development tools will activate the debugging on a per-session basis. Meaning that the debugging will only be active for the user who has activated it. All other users won't be affected by the debugging output. Therefore it is highly recommended to activate the debugging output of Contrexx always through the Development tools on a production system to prevent any other user from being affected by the debugging output.
Manual activation
Note: Is is not recommended to use the manual activation on a productive system! Instead use the Development tools in the Global Configuration section.
The debugging output can be activated/deactivated using the following two commands:
// activate debugging \DBG::activate(); // deactivate debugging \DBG::deactivate();
Both methods activate() and deactivate() accept a bitwise combination of the available debug levels (see #Debug Levels). Therefore you can individually activate/deactivate each debug level throughout your code.
Example:
// activate PHP error-reporting + log to firephp console \DBG::activate(DBG_PHP | DBG_LOG_FIREPHP); [...] // later in the code, activate ADOdb error log to monitor some specific SQL queries \DBG::activate(DBG_ADODB_ERROR); [...] // deactivate ADOdb error log for rest of page request (could be activated again later in the code if needed) \DBG::deactivate(DBG_ADODB_ERROR); // deactivate whole debugging output \DBG::deactivate();
Logging
The methods \DBG::dump() and \DBG::log() can be used to output custom debug information:
// dump variable information (similar to like PHP's var_dump()) \DBG::dump($array); // output a message // (optional) set $type to one of log (default), info or error \DBG::log($message [, $type]);
Tracing
PHP code can be traced using \DBG::trace():
// output method/function name where \DBG::trace() is called \DBG::trace();
Backtrace can be output using \DBG::stack():
// output backtrace (wrapper for PHP's debug_backtrace()) \DBG::stack();
SQL queries can be traced using the debug level DBG_ADODB_TRACE:
// activate SQL query tracing \DBG::activate(DBG_ADODB | DBG_ADODB_TRACE);
Debug Levels
Option | Description | Available since |
---|---|---|
DBG_NONE | Disable all output | 2.1.0 |
DBG_PHP | Output all PHP errors/warnings/notices | 2.1.0 |
DBG_LOG | Output debug messages/events (like DBG::dump(), DBG::msg(), etc) | 3.0.1 |
DBG_DB | Output all database queries
Shortcut for: |
3.0.1 |
DBG_DB_TRACE | Output database queries with backtrace
Shortcut for: |
3.0.1 |
DBG_DB_CHANGE | Output database changes (INSERT/UPDATE/DELETE)
Shortcut for: |
3.0.1 |
DBG_DB_ERROR | Output failed database queries
Shortcut for: |
3.0.1 |
DBG_DOCTRINE | Output database (doctrine) queries | 3.0.1 |
DBG_DOCTRINE_TRACE | Output database (doctrine) queries with backtrace | 3.0.1 |
DBG_DOCTRINE_CHANGE | Output database (doctrine) changes (INSERT/UPDATE/DELETE) | 3.0.1 |
DBG_DOCTRINE_ERROR | Output only failed database (doctrine) queries | 3.0.1 |
DBG_ADODB | Output database (ADOdb) queries | 2.1.0 |
DBG_ADODB_TRACE | Output database (ADOdb) queries with backtrace | 2.1.0 |
DBG_ADODB_CHANGE | Output database (ADOdb) changes (INSERT/UPDATE/DELETE) | 3.0.1 |
DBG_ADODB_ERROR | Output only failed database (ADOdb) queries | 2.1.3 |
DBG_LOG_FILE | Output log to file (dbg.log ). This will either log to /tmp/log/dbg.log or /update/dbg.log depending on which part of the system you're using
|
2.1.0 |
DBG_LOG_FIREPHP | Output log via FirePHP. FirePHP is an extension to Firebug | 2.1.0 |
DBG_ERROR_FIREPHP | Shortcut for:
DBG_PHP | DBG_ADODB_ERROR | DBG_LOG_FIREPHP |
3.0.0 |
DBG_DB_FIREPHP | Shortcut for:
DBG_PHP | DBG_ADODB | DBG_LOG_FIREPHP |
3.0.0 |
DBG_ALL | Note: This option is useless!
Shortcut for: |
- |
Debugging with older Contrexx versions
The helpers DBG::activate() and DBG::deactivate() to control the debugging output are available since Contrexx version 2.1 SP3. See next subsections on how to activate the debugging in older versions prior to version 2.1 SP3.
2.1 (till SP2)
Set constant _DEBUG at the beginning of the files index.php and cadmin/index.php to one of the supported debug levels: <highlightsyntax>// activate PHP error-reporting: define('_DEBUG', DBG_PHP);</highlightsyntax>
2.0
Set constant _DEBUG at the beginning of the files index.php and cadmin/index.php to either true or false to activate PHP error-reporting and ADOdb SQL-query logger: <highlightsyntax>// activate PHP + SQL output: define('_DEBUG', 0);
// deactivate output define('_DEBUG', 1);</highlightsyntax>
1.x
Debugging output must be activated manually using PHP's and ADOdb's nativ debug functions: <highlightsyntax>// activate PHP debugging output error_reporting(E_ALL); ini_set('display_errors', 1);
// activate database debugging $objDatabase->debug = 1;</highlightsyntax>