diff options
author | Matthieu Aubry <mattab@users.noreply.github.com> | 2017-07-24 06:06:24 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-24 06:06:24 +0300 |
commit | ca8971ef9e8cd22bf22d6e805c315a37f2f49b9c (patch) | |
tree | cffe8f5a975ca8f619de187a1200ddd98c3f9283 /core | |
parent | 7214a9b504a79955804e28dce1cdf7583588eb96 (diff) |
Allow logging in Debug level the SQL queries of all log archivers (#11812)
* Debug log archiver queries
* comment out
Diffstat (limited to 'core')
-rw-r--r-- | core/DataAccess/LogAggregator.php | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/core/DataAccess/LogAggregator.php b/core/DataAccess/LogAggregator.php index 4651394556..522a46fe95 100644 --- a/core/DataAccess/LogAggregator.php +++ b/core/DataAccess/LogAggregator.php @@ -10,10 +10,12 @@ namespace Piwik\DataAccess; use Piwik\ArchiveProcessor\Parameters; use Piwik\Common; +use Piwik\Container\StaticContainer; use Piwik\DataArray; use Piwik\Db; use Piwik\Metrics; use Piwik\Tracker\GoalManager; +use Psr\Log\LoggerInterface; /** * Contains methods that calculate metrics by aggregating log data (visits, actions, conversions, @@ -141,16 +143,23 @@ class LogAggregator private $queryOriginHint = ''; /** + * @var LoggerInterface + */ + private $logger; + + + /** * Constructor. * * @param \Piwik\ArchiveProcessor\Parameters $params */ - public function __construct(Parameters $params) + public function __construct(Parameters $params, LoggerInterface $logger = null) { $this->dateStart = $params->getDateStart(); $this->dateEnd = $params->getDateEnd(); $this->segment = $params->getSegment(); $this->sites = $params->getIdSites(); + $this->logger = $logger ?: StaticContainer::get('Psr\Log\LoggerInterface'); } public function setQueryOriginHint($nameOfOrigiin) @@ -169,6 +178,9 @@ class LogAggregator $query['sql'] = 'SELECT /* ' . $this->queryOriginHint . ' */' . substr($query['sql'], strlen($select)); } + // Uncomment to log on DEBUG level all archiving queries + // $this->logger->debug($query['sql']); + return $query; } |