From 1b95e56fa37f829c5a254743a3f589f078872f48 Mon Sep 17 00:00:00 2001 From: Aimeos Date: Tue, 10 Jul 2018 21:57:53 +0200 Subject: [PATCH] Removed unused Flow log adapter --- lib/custom/src/MW/Logger/Flow.php | 94 ---------------------- lib/custom/tests/MW/Logger/FlowTest.php | 100 ------------------------ 2 files changed, 194 deletions(-) delete mode 100644 lib/custom/src/MW/Logger/Flow.php delete mode 100644 lib/custom/tests/MW/Logger/FlowTest.php diff --git a/lib/custom/src/MW/Logger/Flow.php b/lib/custom/src/MW/Logger/Flow.php deleted file mode 100644 index 0b01f29..0000000 --- a/lib/custom/src/MW/Logger/Flow.php +++ /dev/null @@ -1,94 +0,0 @@ -logger = $logger; - } - - - /** - * Writes a message to the configured log facility. - * - * @param string $message Message text that should be written to the log facility - * @param integer $priority Priority of the message for filtering - * @param string $facility Facility for logging different types of messages (e.g. message, auth, user, changelog) - * @throws \Aimeos\MW\Logger\Exception If an error occurs in Zend_Log - * @see \Aimeos\MW\Logger\Base for available log level constants - */ - public function log( $message, $priority = \Aimeos\MW\Logger\Base::ERR, $facility = 'message' ) - { - try - { - if( !is_scalar( $message ) ) { - $message = json_encode( $message ); - } - - $this->logger->log( $message, $this->translatePriority( $priority ) ); - } - catch( \Exception $e ) { - throw new \Aimeos\MW\Logger\Exception( $e->getMessage(), $e->getCode(), $e ); - } - } - - - /** - * Translates the log priority to the log levels of Monolog. - * - * @param integer $priority Log level from \Aimeos\MW\Logger\Base - * @return integer Log level from Monolog\Logger - * @throws \Aimeos\MW\Logger\Exception If log level is unknown - */ - protected function translatePriority( $priority ) - { - switch( $priority ) - { - case \Aimeos\MW\Logger\Base::EMERG: - return LOG_EMERG; - case \Aimeos\MW\Logger\Base::ALERT: - return LOG_ALERT; - case \Aimeos\MW\Logger\Base::CRIT: - return LOG_CRIT; - case \Aimeos\MW\Logger\Base::ERR: - return LOG_ERR; - case \Aimeos\MW\Logger\Base::WARN: - return LOG_WARNING; - case \Aimeos\MW\Logger\Base::NOTICE: - return LOG_NOTICE; - case \Aimeos\MW\Logger\Base::INFO: - return LOG_INFO; - case \Aimeos\MW\Logger\Base::DEBUG: - return LOG_DEBUG; - default: - throw new \Aimeos\MW\Logger\Exception( 'Invalid log level' ); - } - } -} \ No newline at end of file diff --git a/lib/custom/tests/MW/Logger/FlowTest.php b/lib/custom/tests/MW/Logger/FlowTest.php deleted file mode 100644 index 3689d19..0000000 --- a/lib/custom/tests/MW/Logger/FlowTest.php +++ /dev/null @@ -1,100 +0,0 @@ -markTestSkipped( 'Class \\Neos\\Flow\\Log\\Logger not found' ); - } - - $be = new \Neos\Flow\Log\Backend\FileBackend(); - $be->setSeverityThreshold( LOG_ERR ); - $be->setLogFileURL( 'flow.log' ); - - $log = new \Neos\Flow\Log\Logger(); - $log->addBackend( $be ); - - $this->object = new \Aimeos\MW\Logger\Flow( $log ); - } - - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - * - * @access protected - */ - protected function tearDown() - { - @unlink( 'flow.log' ); - } - - - public function testLog() - { - $this->object->log( 'error' ); - $this->assertRegExp( '/^[^ ]+ [^ ]+ [0-9]+[ ]+ERROR[ ]+MW[ ]+error/', file_get_contents( 'flow.log' ) ); - } - - - public function testNonScalarLog() - { - $this->object->log( array( 'error', 'error2', 2 ) ); - $this->assertRegExp( '/^[^ ]+ [^ ]+ [0-9]+[ ]+ERROR[ ]+MW[ ]+\["error","error2",2\]/', file_get_contents( 'flow.log' ) ); - } - - - public function testLogDebug() - { - $this->object->log( 'debug', \Aimeos\MW\Logger\Base::DEBUG ); - $this->assertEquals( '', file_get_contents( 'flow.log' ) ); - } - - - public function testBadPriority() - { - $this->setExpectedException( '\\Aimeos\\MW\\Logger\\Exception' ); - $this->object->log( 'error', -1 ); - } - - - public function testLogPriorityTranslate() - { - $this->object->log( '', \Aimeos\MW\Logger\Base::EMERG ); - $this->object->log( '', \Aimeos\MW\Logger\Base::ALERT ); - $this->object->log( '', \Aimeos\MW\Logger\Base::CRIT ); - $this->object->log( '', \Aimeos\MW\Logger\Base::ERR ); - $this->object->log( '', \Aimeos\MW\Logger\Base::WARN ); - $this->object->log( '', \Aimeos\MW\Logger\Base::NOTICE ); - $this->object->log( '', \Aimeos\MW\Logger\Base::INFO ); - $this->object->log( '', \Aimeos\MW\Logger\Base::DEBUG ); - - $content = file_get_contents( 'flow.log' ); - $this->assertContains( 'EMERGENCY', $content ); - $this->assertContains( 'ALERT', $content ); - $this->assertContains( 'CRITICAL', $content ); - $this->assertContains( 'ERROR', $content ); - } -}