Index: branches/5.2.x/core/kernel/utility/logger.php =================================================================== diff -u -N -r16688 -r16700 --- branches/5.2.x/core/kernel/utility/logger.php (.../logger.php) (revision 16688) +++ branches/5.2.x/core/kernel/utility/logger.php (.../logger.php) (revision 16700) @@ -1,6 +1,6 @@ dbStorage = $this->getDBStorage(); + $system_config = kUtil::getSystemConfig(); $this->_debugMode = $this->Application->isDebugMode(); @@ -241,6 +250,24 @@ } /** + * Create separate connection for logging purposes. + * + * @return kDBConnection + */ + protected function getDBStorage() + { + $system_config = new kSystemConfig(true); + $vars = $system_config->getData(); + $db_class = $this->Application->isDebugMode() ? 'kDBConnectionDebug' : 'kDBConnection'; + + // Can't use "kApplication::makeClass", because class factory isn't initialized at this point. + $db = new $db_class(SQL_TYPE, array($this, 'handleSQLError'), 'logger'); + $db->setup($vars); + + return $db; + } + + /** * Sets state of the logged (enabled/user-only/disabled) * * @param $new_state @@ -768,11 +795,11 @@ $this->_logRecord['LogDate'] = adodb_date('Y-m-d H:i:s'); if ( $storage_medium == self::LS_AUTOMATIC ) { - $storage_medium = $this->Conn->connectionOpened() ? self::LS_DATABASE : self::LS_DISK; + $storage_medium = $this->dbStorage->connectionOpened() ? self::LS_DATABASE : self::LS_DISK; } if ( $storage_medium == self::LS_DATABASE ) { - $result = $this->Conn->doInsert($this->_logRecord, TABLE_PREFIX . 'SystemLog'); + $result = $this->dbStorage->doInsert($this->_logRecord, TABLE_PREFIX . 'SystemLog'); } elseif ( $storage_medium == self::LS_DISK ) { $result = $this->_saveToFile(RESTRICTED . '/system.log'); @@ -823,13 +850,13 @@ public function delete($unique_id, $storage_medium = self::LS_AUTOMATIC) { if ( $storage_medium == self::LS_AUTOMATIC ) { - $storage_medium = $this->Conn->connectionOpened() ? self::LS_DATABASE : self::LS_DISK; + $storage_medium = $this->dbStorage->connectionOpened() ? self::LS_DATABASE : self::LS_DISK; } if ( $storage_medium == self::LS_DATABASE ) { $sql = 'DELETE FROM ' . TABLE_PREFIX . 'SystemLog WHERE LogUniqueId = ' . $unique_id; - $this->Conn->Query($sql); + $this->dbStorage->Query($sql); } elseif ( $storage_medium == self::LS_DISK ) { // TODO: no way to delete a line from a file