Skip to content
Snippets Groups Projects
Commit 9f0dd705 authored by joe's avatar joe Committed by agata
Browse files

Added optional logging

parent 88e04ffd
No related branches found
No related tags found
No related merge requests found
......@@ -55,7 +55,7 @@ define( 'HYPERDB_SERVER_GONE_ERROR', 2006 ); // MySQL server has gone away
class hyperdb extends wpdb {
/**
* A/I patch!
* A/I patch!
* store a FlexiHash() instance here.
*/
var $hash_map;
......@@ -680,16 +680,19 @@ class hyperdb extends wpdb {
$success = false;
$this->last_connection = compact('dbhname', 'host', 'port', 'user', 'name', 'tcp', 'elapsed', 'success');
$this->db_connections[] = $this->last_connection;
$msg = date( "Y-m-d H:i:s" ) . " Can't select $dbhname - \n";
$msg .= "'referrer' => '{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}',\n";
$msg .= "'server' => {$server},\n";
$msg .= "'host' => {$host},\n";
$msg .= "'error' => " . $this->ex_mysql_error() . ",\n";
$msg .= "'errno' => " . $this->ex_mysql_errno() . ",\n";
$msg .= "'server_state' => $server_state\n";
$msg .= "'lagged_status' => " . ( isset( $lagged_status ) ? $lagged_status : HYPERDB_LAG_UNKNOWN );
$this->print_error( $msg );
/* Workaround to stop logging a/i */
if ( AI_LOG_HYPERDB == true ) {
$msg = date( "Y-m-d H:i:s" ) . " Can't select $dbhname - \n";
$msg .= "'referrer' => '{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}',\n";
$msg .= "'server' => {$server},\n";
$msg .= "'host' => {$host},\n";
$msg .= "'error' => " . $this->ex_mysql_error() . ",\n";
$msg .= "'errno' => " . $this->ex_mysql_errno() . ",\n";
$msg .= "'server_state' => $server_state\n";
$msg .= "'lagged_status' => " . ( isset( $lagged_status ) ? $lagged_status : HYPERDB_LAG_UNKNOWN );
$this->print_error( $msg );
}
}
if ( ! $success || ! isset( $this->dbhs[$dbhname] ) || ! $this->is_mysql_connection( $this->dbhs[$dbhname] ) ) {
......@@ -723,8 +726,8 @@ class hyperdb extends wpdb {
$collate = null;
$this->set_charset($this->dbhs[$dbhname], $charset, $collate);
if ( !isset( $charset ) )
if ( !isset( $charset ) )
$charset = null;
if ( !isset( $collate ) )
......@@ -885,7 +888,7 @@ class hyperdb extends wpdb {
if (strpos($_SERVER['REQUEST_URI'], '/wp-admin/') !== false) {
$query .= ' /* NO CACHE */';
}
$this->timer_start();
if ( $statement_before_query ) {
$query_for_log = "$statement_before_query; $query_for_log";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment