diff --git a/src/Factory/LoggerFactory.php b/src/Factory/LoggerFactory.php index 0ab4c2ac2..32a338fb0 100644 --- a/src/Factory/LoggerFactory.php +++ b/src/Factory/LoggerFactory.php @@ -6,8 +6,8 @@ use Friendica\Core\Config\Configuration; use Friendica\Core\Logger; use Friendica\Network\HTTPException\InternalServerErrorException; use Friendica\Util\Introspection; -use Friendica\Util\Logger\Monolog\FriendicaDevelopHandler; -use Friendica\Util\Logger\Monolog\FriendicaIntrospectionProcessor; +use Friendica\Util\Logger\Monolog\DevelopHandler; +use Friendica\Util\Logger\Monolog\IntrospectionProcessor; use Friendica\Util\Logger\ProfilerLogger; use Friendica\Util\Logger\StreamLogger; use Friendica\Util\Logger\SyslogLogger; @@ -67,7 +67,7 @@ class LoggerFactory $logger->pushProcessor(new Monolog\Processor\PsrLogMessageProcessor()); $logger->pushProcessor(new Monolog\Processor\ProcessIdProcessor()); $logger->pushProcessor(new Monolog\Processor\UidProcessor()); - $logger->pushProcessor(new FriendicaIntrospectionProcessor($introspection, LogLevel::DEBUG)); + $logger->pushProcessor(new IntrospectionProcessor($introspection, LogLevel::DEBUG)); $stream = $config->get('system', 'logfile'); @@ -139,9 +139,9 @@ class LoggerFactory $logger->pushProcessor(new Monolog\Processor\PsrLogMessageProcessor()); $logger->pushProcessor(new Monolog\Processor\ProcessIdProcessor()); $logger->pushProcessor(new Monolog\Processor\UidProcessor()); - $logger->pushProcessor(new FriendicaIntrospectionProcessor($introspection, LogLevel::DEBUG)); + $logger->pushProcessor(new IntrospectionProcessor($introspection, LogLevel::DEBUG)); - $logger->pushHandler(new FriendicaDevelopHandler($developerIp)); + $logger->pushHandler(new DevelopHandler($developerIp)); static::addStreamHandler($logger, $stream, LogLevel::DEBUG); break; diff --git a/src/Util/Logger/AbstractFriendicaLogger.php b/src/Util/Logger/AbstractLogger.php similarity index 98% rename from src/Util/Logger/AbstractFriendicaLogger.php rename to src/Util/Logger/AbstractLogger.php index 82f2f56c5..576f4bfb4 100644 --- a/src/Util/Logger/AbstractFriendicaLogger.php +++ b/src/Util/Logger/AbstractLogger.php @@ -16,7 +16,7 @@ use Psr\Log\LogLevel; * - UID for each call * - Channel of the current call (i.e. index, worker, daemon, ...) */ -abstract class AbstractFriendicaLogger implements LoggerInterface +abstract class AbstractLogger implements LoggerInterface { /** * The output channel of this logger diff --git a/src/Util/Logger/Monolog/FriendicaDevelopHandler.php b/src/Util/Logger/Monolog/DevelopHandler.php similarity index 95% rename from src/Util/Logger/Monolog/FriendicaDevelopHandler.php rename to src/Util/Logger/Monolog/DevelopHandler.php index 13a464535..07a839345 100644 --- a/src/Util/Logger/Monolog/FriendicaDevelopHandler.php +++ b/src/Util/Logger/Monolog/DevelopHandler.php @@ -11,7 +11,7 @@ use Monolog\Logger; * If you want to debug only interactions from your IP or the IP of a remote server for federation debug, * you'll use Logger::develop() for the duration of your work, and you clean it up when you're done before submitting your PR. */ -class FriendicaDevelopHandler extends Handler\AbstractHandler +class DevelopHandler extends Handler\AbstractHandler { /** * @var string The IP of the developer who wants to debug diff --git a/src/Util/Logger/Monolog/FriendicaIntrospectionProcessor.php b/src/Util/Logger/Monolog/IntrospectionProcessor.php similarity index 93% rename from src/Util/Logger/Monolog/FriendicaIntrospectionProcessor.php rename to src/Util/Logger/Monolog/IntrospectionProcessor.php index b8e7f5e10..18ea84680 100644 --- a/src/Util/Logger/Monolog/FriendicaIntrospectionProcessor.php +++ b/src/Util/Logger/Monolog/IntrospectionProcessor.php @@ -9,7 +9,7 @@ use Monolog\Processor\ProcessorInterface; /** * Injects line/file//function where the log message came from */ -class FriendicaIntrospectionProcessor implements ProcessorInterface +class IntrospectionProcessor implements ProcessorInterface { private $level; diff --git a/src/Util/Logger/README.md b/src/Util/Logger/README.md index 381bd94ba..449403194 100644 --- a/src/Util/Logger/README.md +++ b/src/Util/Logger/README.md @@ -24,6 +24,4 @@ Each logging implementation should pe capable of printing at least the following - A log message - A context of the log message (f.e which user) -If possible, a Logger should extend [`AbstractFriendicaLogger`](AbstractFriendicaLogger.php), because it contains additional, Friendica specific business logic for each logging call. - -Using AbstractFriendicaLogger makes the logger capable of adding profiling data for each log call. +If possible, a Logger should extend [`AbstractLogger`](AbstractLogger.php), because it contains additional, Friendica specific business logic for each logging call. diff --git a/src/Util/Logger/StreamLogger.php b/src/Util/Logger/StreamLogger.php index 10ad0a097..7e52df80f 100644 --- a/src/Util/Logger/StreamLogger.php +++ b/src/Util/Logger/StreamLogger.php @@ -9,7 +9,7 @@ use Psr\Log\LogLevel; /** * A Logger instance for logging into a stream (file, stdout, stderr) */ -class StreamLogger extends AbstractFriendicaLogger +class StreamLogger extends AbstractLogger { /** * The minimum loglevel at which this logger will be triggered diff --git a/src/Util/Logger/SyslogLogger.php b/src/Util/Logger/SyslogLogger.php index 2d4a5fe31..e21e953ac 100644 --- a/src/Util/Logger/SyslogLogger.php +++ b/src/Util/Logger/SyslogLogger.php @@ -11,7 +11,7 @@ use Psr\Log\LogLevel; * A Logger instance for syslogging (fast, but simple) * @see http://php.net/manual/en/function.syslog.php */ -class SyslogLogger extends AbstractFriendicaLogger +class SyslogLogger extends AbstractLogger { const IDENT = 'Friendica'; diff --git a/tests/src/Util/Logger/StreamLoggerTest.php b/tests/src/Util/Logger/StreamLoggerTest.php index a2e81441b..38706231c 100644 --- a/tests/src/Util/Logger/StreamLoggerTest.php +++ b/tests/src/Util/Logger/StreamLoggerTest.php @@ -124,22 +124,6 @@ class StreamLoggerTest extends MockedTest $this->assertLoglineNums(5, $text); } - - /** - * Test if a file cannot get opened - * @expectedException \UnexpectedValueException - */ - public function testNoFile() - { - $logfile = vfsStream::newFile('friendica.log') - ->at($this->root) - ->chmod(0); - - $logger = new StreamLogger('test', $logfile->url(), $this->introspection); - - $logger->emergency('not working'); - } - /** * Test when a file isn't set * @expectedException \LogicException @@ -153,13 +137,16 @@ class StreamLoggerTest extends MockedTest } /** - * Test when a file doesn't exist + * Test when a file cannot be opened * @expectedException \UnexpectedValueException * @expectedExceptionMessageRegExp /The stream or file .* could not be opened: .* / */ public function testWrongUrl() { - $logger = new StreamLogger('test', 'wrongfile', $this->introspection); + $logfile = vfsStream::newFile('friendica.log') + ->at($this->root)->chmod(0); + + $logger = new StreamLogger('test', $logfile->url(), $this->introspection); $logger->emergency('not working'); } @@ -171,7 +158,7 @@ class StreamLoggerTest extends MockedTest */ public function testWrongDir() { - $logger = new StreamLogger('test', 'a/wrong/directory/file.txt', $this->introspection); + $logger = new StreamLogger('test', '/a/wrong/directory/file.txt', $this->introspection); $logger->emergency('not working'); }