From 0a033767db51d17439bfbd16bb0558327f1fc7a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 12 May 2017 13:13:19 +0200 Subject: [PATCH] Added logger when we match Tagging rules --- src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php | 9 ++++++++- src/Wallabag/CoreBundle/Resources/config/services.yml | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php b/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php index b490e2090..add27db2b 100644 --- a/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php +++ b/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php @@ -8,6 +8,7 @@ use Wallabag\CoreBundle\Entity\Tag; use Wallabag\CoreBundle\Repository\EntryRepository; use Wallabag\CoreBundle\Repository\TagRepository; use Wallabag\UserBundle\Entity\User; +use Psr\Log\LoggerInterface; class RuleBasedTagger { @@ -15,11 +16,12 @@ class RuleBasedTagger private $tagRepository; private $entryRepository; - public function __construct(RulerZ $rulerz, TagRepository $tagRepository, EntryRepository $entryRepository) + public function __construct(RulerZ $rulerz, TagRepository $tagRepository, EntryRepository $entryRepository, LoggerInterface $logger) { $this->rulerz = $rulerz; $this->tagRepository = $tagRepository; $this->entryRepository = $entryRepository; + $this->logger = $logger; } /** @@ -36,6 +38,11 @@ class RuleBasedTagger continue; } + $this->logger->info('Matching rule.', [ + 'rule' => $rule->getRule(), + 'tags' => $rule->getTags(), + ]); + foreach ($rule->getTags() as $label) { $tag = $this->getTag($label); diff --git a/src/Wallabag/CoreBundle/Resources/config/services.yml b/src/Wallabag/CoreBundle/Resources/config/services.yml index 6c9195ce5..a9134ac3b 100644 --- a/src/Wallabag/CoreBundle/Resources/config/services.yml +++ b/src/Wallabag/CoreBundle/Resources/config/services.yml @@ -99,6 +99,7 @@ services: - "@rulerz" - "@wallabag_core.tag_repository" - "@wallabag_core.entry_repository" + - "@logger" # repository as a service wallabag_core.entry_repository: