| Information | |
|---|---|
| min. EQDKP-PLUS Version | 0.7.0.0
|
Contents |
The Plus Debug Logger (PDL) is the central point for debug messages in 0.7 instead of the local solutions used by various developers in the current system. It performs the task of an error handler for php errors as well.
The PDL is initialised early in the common.php and can be globally reached by using the $pdl object. Every debug message is associated to a type. Predefined types are "unknown", "php_error", "sql_error", "sql_query", "pdc_query" and "pdh_error" but of course you can (and should if you want to log custom errors) also register your own types.
Example call:
$pdl->register_type("sql_error", null, array($this, 'psl_html_format_sql_error'), array(2,3), true);
The register_type function takes 4 parameters:
Note: The html function is a method of the current object in this case, it could also be the name of a globally known function!
If you want to log something you just call the log method like this:
$pdl->log("sql_error", $sql, $error['message'], $error['code'], $dbname, $table_prefix);
The first parameter always has to be the log type, followed by an arbitrary number of other parameters, which will be stored and can be used in the output format functions.
An html output format function might look like this example:
function pdl_html_format_sql_error($log_entry){ global $eqdkp_root_path; $text = '<b>Query:</b>' . $log_entry['args'][0] . '<br /><br /> <b>Message:</b>' . $log_entry['args'][1] . '<br /><br /> <b>Code:</b>' . $log_entry['args'][2] . '<br /> <b>Database:</b>' . $log_entry['args'][3] . '<br /> <b>Table Prefix:</b>' . $log_entry['args'][4] . '<br />'; return $text; }
Whereas the passed $log_entry variable looks like this:
$log_entry['timestamp'] = TIMESTAMP; $log_entry['args'] = array();
It contains an auto generated timestamp and an array containing the parameters passed to the log call.