1
0
قرینه از https://github.com/matomo-org/matomo.git synced 2025-08-22 15:07:44 +00:00
Files
matomo/tests/PHPUnit/Framework/Mock/FakeLogger.php
Stefan Giehl 065efa10af Encapsulate plugins from using Matomo dependencies directly by introducing vendor proxy patterns (#20596)
* Adds proxy class for DI methods

* use di proxy class

* introduce proxy classes for logging

* use proxy classes

* submodule updates

* fix typos

* replace useage of DI\object with DI\autowire

* Provide method to ask for confirmation in console method (capsulates usage of ConfirmationQuestion)

* provide methods for using console helpers, instead of direct usage in plugins

* refactor our console commands so they don't need to typehint input and output interfaces

* Add proxy methods to add command options

without using InputOption constants

* Add proxy methods to add command arguments

without using InputArgument constants

* fix typo

* proxy dependency exceptions

* adjustments and fixes

* use a custom di container class and di exceptions

* submodule update

* fix test

* improve inline documentation

* disallow using getHelper method in console commands

* Ensure trim is always passed a string param

Co-authored-by: Ben Burgess <88810029+bx80@users.noreply.github.com>

* submodule updates

* submodule updates

---------

Co-authored-by: Michal Kleiner <michal@innocraft.com>
Co-authored-by: Ben Burgess <88810029+bx80@users.noreply.github.com>
2023-05-02 12:08:16 +02:00

37 خطوط
791 B
PHP

<?php
namespace Piwik\Tests\Framework\Mock;
use Monolog\Processor\PsrLogMessageProcessor;
use Psr\Log\AbstractLogger;
use Piwik\Log\LoggerInterface;
class FakeLogger extends AbstractLogger implements LoggerInterface
{
/**
* @var string
*/
public $output = '';
/**
* @var PsrLogMessageProcessor
*/
private $processor;
public function __construct()
{
$this->processor = new PsrLogMessageProcessor();
}
public function log($level, $message, array $context = array())
{
if (strpos($message, 'Running command') !== false) {
return;
}
$record = $this->processor->__invoke(array('message' => $message, 'context' => $context));
$this->output .= $record['message'] . PHP_EOL;
}
}