improve logging
authorPhilipp Schüle <p.schuele@metaways.de>
Tue, 24 Jan 2017 18:59:26 +0000 (19:59 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Wed, 25 Jan 2017 11:05:00 +0000 (12:05 +0100)
* Tinebase_Container
* Tinebase_Import_Abstract

Change-Id: I9ffa17cac2830d89e593d85b658077c4c98d4163
Reviewed-on: http://gerrit.tine20.com/customers/4132
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Tinebase/Container.php
tine20/Tinebase/Import/Abstract.php

index e765fb7..0daf008 100644 (file)
@@ -775,7 +775,7 @@ class Tinebase_Container extends Tinebase_Backend_Sql_Abstract implements Tineba
             $defaultContainerId = Tinebase_Core::getPreference($meta['appName'])->getValueForUser($defaultContainerPreferenceName, $account->getId());
             try {
                 $result = $this->getContainerById($defaultContainerId);
-                Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__
+                if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__
                     . ' Got default container from preferences: ' . $result->name);
                 return $result;
             } catch (Tinebase_Exception $te) {
index 5b6978d..4ff62c1 100644 (file)
@@ -665,7 +665,14 @@ abstract class Tinebase_Import_Abstract implements Tinebase_Import_Interface
                 array('field' => $field['filter'], 'operator' => $operator, 'value' => $value . $filterValueToAdd)
         ));
         $result = $controller->search($filter, null, /* $_getRelations */ true);
-        return $result->getFirstRecord();
+        $relatedRecord = $result->getFirstRecord();
+
+        if ($relatedRecord && Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
+            Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__
+                . ' Found related record: ' . print_r($relatedRecord->toArray(), true));
+        }
+
+        return $relatedRecord;
     }
 
     protected function _getRelationData($record, $field, $data, $value)
@@ -682,7 +689,10 @@ abstract class Tinebase_Import_Abstract implements Tinebase_Import_Interface
             $relation['related_id'] = $record->getId();
             $recordArray = $record->toArray();
         } else {
-            // create new related record
+            if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
+                Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__
+                    . ' Create new related record');
+            }
             $recordArray = array(
                 (isset($field['related_field']) ? $field['related_field'] : $field['filter']) => $value
             );
@@ -691,6 +701,11 @@ abstract class Tinebase_Import_Abstract implements Tinebase_Import_Interface
             }
         }
 
+        if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
+            Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__
+                . ' Import data:' . print_r($data, true));
+        }
+
         // add more data for this relation if available
         foreach ($data as $key => $value) {
             $regex = '/^' . preg_quote($relationType) . '_/';
@@ -703,6 +718,11 @@ abstract class Tinebase_Import_Abstract implements Tinebase_Import_Interface
         // we don't need related record relations
         unset($recordArray['relations']);
 
+        if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
+            Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__
+                . ' Related record: ' . print_r($recordArray, true));
+        }
+
         $relation['related_record'] = $recordArray;
 
         return $relation;