Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiosmosis <diosmosis@users.noreply.github.com>2019-10-01 06:23:18 +0300
committerGitHub <noreply@github.com>2019-10-01 06:23:18 +0300
commit42a62a21cb5c2df97e0b6fe64ecc2c5ea426f119 (patch)
tree3f5742d11026dfd9bc6866415630cc492e87f649 /plugins/Monolog
parent416697204ae953c4da6c2bfd9c70562021b4b1c8 (diff)
Replace some usages of Common::printDebug w/ use of logger (#13968)
* Start refactoring Common::printDebug(). * Make tracker debug statement error log. * Remove logger removal for tracker. * Fix test failure. * Add two more parent constructor calls. * Fix failing test
Diffstat (limited to 'plugins/Monolog')
-rw-r--r--plugins/Monolog/config/config.php6
-rw-r--r--plugins/Monolog/config/tracker.php16
-rw-r--r--plugins/Monolog/tests/System/TrackerLoggingTest.php15
3 files changed, 18 insertions, 19 deletions
diff --git a/plugins/Monolog/config/config.php b/plugins/Monolog/config/config.php
index ff60f7c5bd..18e07c5c33 100644
--- a/plugins/Monolog/config/config.php
+++ b/plugins/Monolog/config/config.php
@@ -40,7 +40,10 @@ return array(
$writers = [];
foreach ($writerNames as $writerName) {
- if ($writerName === 'screen' && \Piwik\Common::isPhpCliMode()) {
+ if ($writerName === 'screen'
+ && \Piwik\Common::isPhpCliMode()
+ && !defined('PIWIK_TEST_MODE')
+ ) {
continue; // screen writer is only valid for web requests
}
@@ -112,6 +115,7 @@ return array(
return Log::getMonologLevel(constant('Piwik\Log::'.strtoupper($level)));
}
}
+
return Logger::WARNING;
}),
diff --git a/plugins/Monolog/config/tracker.php b/plugins/Monolog/config/tracker.php
index 620101ff7a..bb7820f9f1 100644
--- a/plugins/Monolog/config/tracker.php
+++ b/plugins/Monolog/config/tracker.php
@@ -10,17 +10,13 @@ function isTrackerDebugEnabled(ContainerInterface $c)
return array(
- 'Psr\Log\LoggerInterface' => \DI\decorate(function ($previous, ContainerInterface $c) {
- if (isTrackerDebugEnabled($c)) {
- return $previous;
- } else {
- return new \Psr\Log\NullLogger();
- }
- }),
-
- 'log.handler.classes' => DI\decorate(function ($previous) {
- if (isset($previous['screen'])) {
+ 'log.handler.classes' => DI\decorate(function ($previous, ContainerInterface $c) {
+ if (isset($previous['screen'])
+ && isTrackerDebugEnabled($c)
+ ) {
$previous['screen'] = 'Piwik\Plugins\Monolog\Handler\EchoHandler';
+ } else {
+ unset($previous['screen']);
}
return $previous;
diff --git a/plugins/Monolog/tests/System/TrackerLoggingTest.php b/plugins/Monolog/tests/System/TrackerLoggingTest.php
index a7b2fe2025..44a7755e9f 100644
--- a/plugins/Monolog/tests/System/TrackerLoggingTest.php
+++ b/plugins/Monolog/tests/System/TrackerLoggingTest.php
@@ -15,6 +15,7 @@ use Piwik\Tests\Framework\Fixture;
use Piwik\Tests\Framework\TestCase\SystemTestCase;
use Piwik\Tests\Framework\TestingEnvironmentVariables;
use PiwikTracker;
+use Psr\Container\ContainerInterface;
/**
* @group Monolog
@@ -75,11 +76,10 @@ class TrackerLoggingTest extends SystemTestCase
{
$response = $t->doTrackPageView('incredible title!');
- $this->assertStringStartsWith("DEBUG: Debug enabled - Input parameters:
-DEBUG: array (
-DEBUG: 'idsite' => '1',
-DEBUG: 'rec' => '1',
-DEBUG: 'apiv' => '1',", $response);
+ $this->assertStringStartsWith("DEBUG: Debug enabled - Input parameters: array (
+ 'idsite' => '1',
+ 'rec' => '1',
+ 'apiv' => '1',", $response);
}
private function setTrackerConfig($trackerConfig)
@@ -96,11 +96,10 @@ DEBUG: 'apiv' => '1',", $response);
'Psr\Log\LoggerInterface' => \DI\get('Monolog\Logger'),
Config::class => \DI\decorate(function (Config $config) {
$config->tests['enable_logging'] = 1;
+ $config->log['log_writers'] = ['screen'];
return $config;
}),
- 'log.handlers' => [
- \DI\get(EchoHandler::class),
- ],
+ 'Tests.log.allowAllHandlers' => true,
);
}