diff --git a/Engine.php b/Engine.php index b0b8680..7402886 100644 --- a/Engine.php +++ b/Engine.php @@ -5,11 +5,13 @@ use Field; use Config; use App; +use Common; use ZCRMModule; use ZCRMRecord; use ZCRMRestClient; use ZCRMNote; +use ZCRMJunctionRecord; use Acms\Plugins\Zoho\Api; class Engine @@ -101,9 +103,7 @@ private function makeLabelConversionTable() $this->conversions = $conversions; App::checkException(); } catch (\Exception $e) { - if (DEBUG_MODE) { - var_dump(__FUNCTION__ . ': ' . $e->getMessage()); - } + $this->warning(__FUNCTION__, $e); } } @@ -275,9 +275,7 @@ private function checkUniqueKeyExists($fields, $scope, $uniqueKey) $responses = $bulkAPIResponse->getData(); continue; } catch (\Exception $e) { - if (DEBUG_MODE) { - var_dump(__FUNCTION__ . ': ' . $e->getMessage()); - } + $this->warning(__FUNCTION__, $e); } } $newFields[] = $field; @@ -305,9 +303,7 @@ private function getFieldsWhereNotExistInContact($fields, $scope, $uniqueKey) continue; } } catch (\Exception $e) { - if (DEBUG_MODE) { - var_dump(__FUNCTION__ . ': ' . $e->getMessage()); - } + $this->warning(__FUNCTION__, $e); } } } @@ -343,9 +339,7 @@ private function addIdsToRecords($records, $scope, $uniqueKey, $fields) $newRecords[] = $record; } } catch (\Exception $e) { - if (DEBUG_MODE) { - var_dump(__FUNCTION__ . ': ' . $e->getMessage()); - } + $this->warning(__FUNCTION__, $e); } } return $newRecords; @@ -435,9 +429,7 @@ private function insertRecords($records) ); } } catch (\Exception $e) { - if (DEBUG_MODE) { - var_dump(__FUNCTION__ . ': ' . $e->getMessage()); - } + $this->warning(__FUNCTION__, $e); } } } @@ -469,9 +461,7 @@ private function updateRecords($records) ); } } catch (\Exception $e) { - if (DEBUG_MODE) { - var_dump(__FUNCTION__ . ': ' . $e->getMessage()); - } + $this->warning(__FUNCTION__, $e); } } } @@ -518,9 +508,7 @@ private function updateRelatedRecords() try { $parentRecord->update(); } catch (\Exception $e) { - if (DEBUG_MODE) { - var_dump(__FUNCTION__ . ': ' . $e->getMessage()); - } + $this->warning(__FUNCTION__, $e); } } } else { @@ -532,4 +520,20 @@ private function updateRelatedRecords() } } } + + /** + * 警告ログの出力 + * + * @param string $methodName + * @param Exception $e + */ + private function warning(string $methodName, \Exception $e) + { + $log = 'ACMS Warning: Zoho plugin, ' . $methodName . ': ' . $e->getMessage(); + if (class_exists('AcmsLogger')) { + \AcmsLogger::warning($log, Common::exceptionArray($e)); + } else { + userErrorLog($log); + } + } }