Merge branch 'develop' into refactor-logger-class-with-logger-object

This commit is contained in:
Art4 2025-01-13 19:19:45 +00:00
commit 1a391fc9c3
2 changed files with 25 additions and 22 deletions

View file

@ -15,7 +15,17 @@ use Friendica\Util\Profiler;
use Psr\Log\LoggerInterface;
/**
* Manager for the core logging instances
* Bridge for the legacy Logger factory.
*
* This class can be removed after the following classes are replaced or
* refactored implementing the `\Friendica\Core\Logger\Factory\LoggerFactory`:
*
* - Friendica\Core\Logger\Factory\StreamLogger
* - Friendica\Core\Logger\Factory\SyslogLogger
* - monolog addon: Friendica\Addon\monolog\src\Factory\Monolog
*
* @see \Friendica\Core\Logger\Factory\StreamLogger
* @see \Friendica\Core\Logger\Factory\SyslogLogger
*/
final class LegacyLoggerFactory implements LoggerFactory
{

View file

@ -21,12 +21,25 @@ use Psr\Log\NullLogger;
class LoggerManagerTest extends TestCase
{
public function testGetLoggerReturnsPsrLogger(): void
/**
* Clean the private static properties
*
* @see LoggerManager::$logger
* @see LoggerManager::$logChannel
*/
protected function tearDown(): void
{
$reflectionProperty = new \ReflectionProperty(LoggerManager::class, 'logger');
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue(null, null);
$reflectionProperty = new \ReflectionProperty(LoggerManager::class, 'logChannel');
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue(null, LogChannel::DEFAULT);
}
public function testGetLoggerReturnsPsrLogger(): void
{
$factory = new LoggerManager(
$this->createStub(IManageConfigValues::class),
$this->createStub(LoggerFactory::class)
@ -37,10 +50,6 @@ class LoggerManagerTest extends TestCase
public function testGetLoggerReturnsSameObject(): void
{
$reflectionProperty = new \ReflectionProperty(LoggerManager::class, 'logger');
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue(null, null);
$factory = new LoggerManager(
$this->createStub(IManageConfigValues::class),
$this->createStub(LoggerFactory::class)
@ -56,10 +65,6 @@ class LoggerManagerTest extends TestCase
['system', 'debugging', null, false],
]);
$reflectionProperty = new \ReflectionProperty(LoggerManager::class, 'logger');
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue(null, null);
$factory = new LoggerManager(
$config,
$this->createStub(LoggerFactory::class)
@ -76,10 +81,6 @@ class LoggerManagerTest extends TestCase
['system', 'profiling', null, true],
]);
$reflectionProperty = new \ReflectionProperty(LoggerManager::class, 'logger');
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue(null, null);
$factory = new LoggerManager(
$config,
$this->createStub(LoggerFactory::class)
@ -96,10 +97,6 @@ class LoggerManagerTest extends TestCase
['system', 'profiling', null, true],
]);
$reflectionProperty = new \ReflectionProperty(LoggerManager::class, 'logger');
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue(null, null);
$factory = new LoggerManager(
$config,
$this->createStub(LoggerFactory::class)
@ -120,10 +117,6 @@ class LoggerManagerTest extends TestCase
['system', 'profiling', null, true],
]);
$reflectionProperty = new \ReflectionProperty(LoggerManager::class, 'logger');
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue(null, null);
$factory = new LoggerManager(
$config,
$this->createStub(LoggerFactory::class)