From 74ee3e9823ccc1bc51ba75fe1003acf7cd6f377b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Fri, 13 Jun 2014 01:52:57 +0200 Subject: [PATCH] Improved SQL error logging --- htdocs/core/db/mssql.class.php | 3 ++- htdocs/core/db/mysqli.class.php | 3 ++- htdocs/core/db/pgsql.class.php | 5 ++++- htdocs/core/db/sqlite.class.php | 4 +++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/htdocs/core/db/mssql.class.php b/htdocs/core/db/mssql.class.php index 2b2bcecfe03..d0b454168df 100644 --- a/htdocs/core/db/mssql.class.php +++ b/htdocs/core/db/mssql.class.php @@ -373,7 +373,8 @@ class DoliDBMssql extends DoliDB $this->lasterror = $this->error(); $this->lasterrno = $row["code"]; - dol_syslog(get_class($this)."::query SQL error: ".$this->lasterror." (".$this->lasterrno.")", LOG_ERR); + dol_syslog(get_class($this)."::query SQL Error query: ".$query, LOG_ERR); + dol_syslog(get_class($this)."::query SQL Error message: ".$this->lasterror." (".$this->lasterrno.")", LOG_ERR); } $this->lastquery=$query; $this->_results = $ret; diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 0575cbcb882..da16c1a7971 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -276,7 +276,8 @@ class DoliDBMysqli extends DoliDB $this->lasterror = $this->error(); $this->lasterrno = $this->errno(); - dol_syslog(get_class($this)."::query SQL error: ".$this->lasterror." (".$this->lasterrno.")", LOG_ERR); + dol_syslog(get_class($this)."::query SQL Error query: ".$query, LOG_ERR); + dol_syslog(get_class($this)."::query SQL Error message: ".$this->lasterror." (".$this->lasterrno.")", LOG_ERR); } $this->lastquery=$query; $this->_results = $ret; diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 7b827e01377..f6759e087c8 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -506,7 +506,10 @@ class DoliDBPgsql extends DoliDB $this->lasterror = $this->error(); $this->lasterrno = $this->errno(); } - dol_syslog(get_class($this)."::query SQL error usesavepoint = ".$usesavepoint." - ".$this->lasterror." (".$this->lasterrno.")", LOG_ERR); + + dol_syslog(get_class($this)."::query SQL Error query: ".$query, LOG_ERR); + dol_syslog(get_class($this)."::query SQL Error message: ".$this->lasterror." (".$this->lasterrno.")", LOG_ERR); + dol_syslog(get_class($this)."::query SQL error usesavepoint = ".$usesavepoint, LOG_ERR); if ($usesavepoint && $this->transaction_opened) // Warning, after that errno will be erased { diff --git a/htdocs/core/db/sqlite.class.php b/htdocs/core/db/sqlite.class.php index dadd4fa7b83..34ee2a41b6d 100644 --- a/htdocs/core/db/sqlite.class.php +++ b/htdocs/core/db/sqlite.class.php @@ -410,7 +410,9 @@ class DoliDBSqlite extends DoliDB $this->lasterror = $this->error(); $this->lasterrno = $this->errno(); - $errormsg = get_class($this)."::query SQL error: ".$this->lasterror; + dol_syslog(get_class($this)."::query SQL Error query: ".$query, LOG_ERR); + + $errormsg = get_class($this)."::query SQL Error message: ".$this->lasterror; if (preg_match('/[0-9]/',$this->lasterrno)) { $errormsg .= ' ('.$this->lasterrno.')';