From cede55836d3800944d1266859e9166ebfe243654 Mon Sep 17 00:00:00 2001 From: Laurent Laffont <llaffont@afi-sa.fr> Date: Tue, 25 Apr 2017 10:56:33 +0200 Subject: [PATCH] hotline #55142 log API harmonization addError -> error --- library/Class/Cata/Log.php | 4 ++-- library/Class/Cosmogramme/Integration/PhaseBatchs.php | 6 +++--- library/Class/Cosmogramme/Integration/PhaseNotice.php | 2 +- library/Class/Cosmogramme/Integration/PhasePanier.php | 8 ++++---- library/Class/Systeme/Report/Publication.php | 2 +- tests/library/Class/Cata/LogTest.php | 6 +++--- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/library/Class/Cata/Log.php b/library/Class/Cata/Log.php index 438b4acbcec..716ea1f81b6 100644 --- a/library/Class/Cata/Log.php +++ b/library/Class/Cata/Log.php @@ -53,8 +53,8 @@ class Class_Cata_Log { } - public function addError($message, $targets = ['default']) { - return $this->_targetsDo($targets, 'addError', [$message]); + public function error($message, $targets = ['default']) { + return $this->_targetsDo($targets, 'error', [$message]); } diff --git a/library/Class/Cosmogramme/Integration/PhaseBatchs.php b/library/Class/Cosmogramme/Integration/PhaseBatchs.php index a48830825fe..1392694e093 100644 --- a/library/Class/Cosmogramme/Integration/PhaseBatchs.php +++ b/library/Class/Cosmogramme/Integration/PhaseBatchs.php @@ -69,10 +69,10 @@ class Class_Cosmogramme_Integration_PhaseBatchs $this->_chrono->endFile())); } catch (Exception $e) { - $this->_log->addError($this->_('Erreur lors de l\'execution du batch %s', + $this->_log->error($this->_('Erreur lors de l\'execution du batch %s', $batch->getLibelle())); - $this->_log->addError($e->getMessage()); - $this->_log->addError($e->getTraceAsString()); + $this->_log->error($e->getMessage()); + $this->_log->error($e->getTraceAsString()); } $this->_chrono->startOnFile(); diff --git a/library/Class/Cosmogramme/Integration/PhaseNotice.php b/library/Class/Cosmogramme/Integration/PhaseNotice.php index 31722a41b25..bc2e2b22efc 100644 --- a/library/Class/Cosmogramme/Integration/PhaseNotice.php +++ b/library/Class/Cosmogramme/Integration/PhaseNotice.php @@ -57,7 +57,7 @@ class Class_Cosmogramme_Integration_PhaseNotice $data_source = $integration->getDataSource(); if (!$data_source->isHttp() && !$this->getFileSystem()->filesize($data_source->getUri())) { - $this->_log->addError($this->_('Le fichier d\'import total est vide : aucun exemplaire supprimé.')); + $this->_log->error($this->_('Le fichier d\'import total est vide : aucun exemplaire supprimé.')); return; } diff --git a/library/Class/Cosmogramme/Integration/PhasePanier.php b/library/Class/Cosmogramme/Integration/PhasePanier.php index 600af5daea6..f0fa6567d8f 100644 --- a/library/Class/Cosmogramme/Integration/PhasePanier.php +++ b/library/Class/Cosmogramme/Integration/PhasePanier.php @@ -91,14 +91,14 @@ class Class_Cosmogramme_Integration_PhasePanier extends Class_Cosmogramme_Integr protected function importBasketRecord($datas, $integration) { if(!$map = $this->mapRecordColumns($integration, $datas)) - return $this->_log->addError($this->_('Pas de donnée trouvée avec le profil de données sélectionné')); + return $this->_log->error($this->_('Pas de donnée trouvée avec le profil de données sélectionné')); if(!$map['libelle']) - return $this->_log->addError($this->_('Ligne non traitée car le libellé n\'a pas pu être lu')); + return $this->_log->error($this->_('Ligne non traitée car le libellé n\'a pas pu être lu')); if (!$exemplaire = Class_Exemplaire::findFirstBy(['id_origine' => $map['id_notice_sigb'], 'id_int_bib' => $integration->getIdBib()])) { - $this->_log->addError($this->_('L\'exemplaire id_origine : %s / id_int_bib : %s n\'a pas été trouvé.', + $this->_log->error($this->_('L\'exemplaire id_origine : %s / id_int_bib : %s n\'a pas été trouvé.', $map['id_notice_sigb'], $integration->getIdBib())); $exemplaire = new Class_Entity(); @@ -107,7 +107,7 @@ class Class_Cosmogramme_Integration_PhasePanier extends Class_Cosmogramme_Integr $owners = $this->findPossibleOwnersOfBasketRecord($map); if ($owners->isEmpty()) { $user = Class_Users::find(1); - $this->_log->addError($this->_('Le panier "%s" est orphelin. Il sera rattaché à l\'utilisateur "%s"', + $this->_log->error($this->_('Le panier "%s" est orphelin. Il sera rattaché à l\'utilisateur "%s"', $map['libelle'], $user->getLogin())); $owners->addAll([$user]); diff --git a/library/Class/Systeme/Report/Publication.php b/library/Class/Systeme/Report/Publication.php index e7e1b671296..0e29370c138 100644 --- a/library/Class/Systeme/Report/Publication.php +++ b/library/Class/Systeme/Report/Publication.php @@ -38,7 +38,7 @@ class Class_Systeme_Report_Publication extends Class_WebService_Abstract { $this->getHttpClient()->postData($url, ['report' => $json]); } catch (Exception $e) { - $log->addError($this->_('Echec de la publication du rapport sur %s (%s)', + $log->error($this->_('Echec de la publication du rapport sur %s (%s)', $url, $e->getMessage())); } diff --git a/tests/library/Class/Cata/LogTest.php b/tests/library/Class/Cata/LogTest.php index f2ba3ab2471..5f457bf5cf0 100644 --- a/tests/library/Class/Cata/LogTest.php +++ b/tests/library/Class/Cata/LogTest.php @@ -29,7 +29,7 @@ class Class_Cata_LogTest extends ModelTestCase { }; $mock = $this->mock(); - foreach(['log', 'info', 'addSuccess', 'addError'] as $method) + foreach(['log', 'info', 'addSuccess', 'error'] as $method) $mock->whenCalled($method)->willDo($append_log); return $mock; } @@ -53,8 +53,8 @@ class Class_Cata_LogTest extends ModelTestCase { ->info('Gather ingredients', '*') ->addSuccess('250g Sugar') ->addSuccess('250g Butter') - ->addError('Not enough Butter', 'default') - ->addError('Go buy butter', '*') + ->error('Not enough Butter', 'default') + ->error('Go buy butter', '*') ->log('Then eat', 'nowhere'); } -- GitLab