From f2da77e6f4b87543c91a5baecbcd144d744cd585 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 20 Jun 2014 17:19:17 -0700 Subject: [PATCH] CRM-12856 - CRM_Core_Lock - Quieter logs The log is very noisy (adding several log lines on most page requests). This might be useful for debugging lock issues, but that's a developer task, so we'll only do it if CIVICRM_LOCK_DEBUG is defined. --- CRM/Core/Lock.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/CRM/Core/Lock.php b/CRM/Core/Lock.php index a3a4dc9ad0..c3e306055b 100644 --- a/CRM/Core/Lock.php +++ b/CRM/Core/Lock.php @@ -66,7 +66,9 @@ class CRM_Core_Lock { else { $this->_name = $database . '.' . $domainID . '.' . $name; } - CRM_Core_Error::debug_log_message('trying to construct lock for ' . $this->_name); + if (defined('CIVICRM_LOCK_DEBUG')) { + CRM_Core_Error::debug_log_message('trying to construct lock for ' . $this->_name); + } static $jobLog = FALSE; if ($jobLog && CRM_Core_DAO::singleValueQuery("SELECT IS_USED_LOCK( '{$jobLog}')")) { return $this->hackyHandleBrokenCode($jobLog); @@ -74,7 +76,9 @@ class CRM_Core_Lock { if (stristr($name, 'civimail.job.')) { $jobLog = $this->_name; } + //if (defined('CIVICRM_LOCK_DEBUG')) { //CRM_Core_Error::debug_var('backtrace', debug_backtrace()); + //} $this->_timeout = $timeout !== NULL ? $timeout : self::TIMEOUT; $this->acquire(); @@ -85,7 +89,9 @@ class CRM_Core_Lock { } function acquire() { - CRM_Core_Error::debug_log_message('aquire lock for ' . $this->_name); + if (defined('CIVICRM_LOCK_DEBUG')) { + CRM_Core_Error::debug_log_message('acquire lock for ' . $this->_name); + } if (!$this->_hasLock) { $query = "SELECT GET_LOCK( %1, %2 )"; $params = array( @@ -137,7 +143,9 @@ class CRM_Core_Lock { if (stristr($this->_name, 'job')) { throw new CRM_Core_Exception('lock aquisition for ' . $this->_name . 'attempted when ' . $jobLog . 'is not released'); } - CRM_Core_Error::debug_log_message('(CRM-12856) faking lock for ' . $this->_name); + if (defined('CIVICRM_LOCK_DEBUG')) { + CRM_Core_Error::debug_log_message('(CRM-12856) faking lock for ' . $this->_name); + } $this->_hasLock = TRUE; return TRUE; } -- 2.25.1