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

Added optional logging

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