diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php index 768af74f25c1f91429694cc7c5cbc36919b3aa84..4fd2782a9b7bd84a4c9932536f40fd70b1fddf24 100644 --- a/module/VuFind/config/module.config.php +++ b/module/VuFind/config/module.config.php @@ -267,6 +267,12 @@ $config = array( $catalog->setConfig($config->Catalog); return $catalog; }, + 'logger' => function ($sm) { + $logger = new \VuFind\Log\Logger(); + $logger->setServiceLocator($sm); + $logger->setConfig(\VuFind\Config\Reader::getConfig()); + return $logger; + }, 'worldcatconnection' => function ($sm) { $wc = new \VuFind\Connection\WorldCat(); $wc->setLogger($sm->get('Logger')); @@ -282,7 +288,6 @@ $config = array( 'authmanager' => 'VuFind\Auth\Manager', 'cart' => 'VuFind\Cart', 'cachemanager' => 'VuFind\Cache\Manager', - 'logger' => 'VuFind\Log\Logger', 'recordloader' => 'VuFind\Record\Loader', 'searchspecsreader' => 'VuFind\Config\SearchSpecsReader', 'sessionmanager' => 'Zend\Session\SessionManager', diff --git a/module/VuFind/src/VuFind/Log/Logger.php b/module/VuFind/src/VuFind/Log/Logger.php index a9db538efa8d80cd116611a80062bbf87d441684..c78d3c56e2883f2092490a677776e104ac4d797f 100644 --- a/module/VuFind/src/VuFind/Log/Logger.php +++ b/module/VuFind/src/VuFind/Log/Logger.php @@ -26,9 +26,11 @@ * @link http://vufind.org Main Site */ namespace VuFind\Log; -use VuFind\Config\Reader as ConfigReader, VuFind\Mailer, +use VuFind\Mailer, Zend\Db\TableGateway\Feature\GlobalAdapterFeature as DbGlobalAdapter, - Zend\Log\Logger as BaseLogger; + Zend\Log\Logger as BaseLogger, + Zend\ServiceManager\ServiceLocatorAwareInterface, + Zend\ServiceManager\ServiceLocatorInterface; /** * This class wraps the BaseLogger class to allow for log verbosity @@ -39,19 +41,31 @@ use VuFind\Config\Reader as ConfigReader, VuFind\Mailer, * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://vufind.org Main Site */ -class Logger extends BaseLogger +class Logger extends BaseLogger implements ServiceLocatorAwareInterface { + /** + * Is debug logging enabled? + * + * @var bool + */ protected $debugNeeded = false; /** - * Constructor + * Service locator + * + * @var ServiceLocatorInterface */ - public function __construct() - { - parent::__construct(); - - $config = ConfigReader::getConfig(); + protected $serviceLocator; + /** + * Set configuration + * + * @param \Zend\Config\Config $config VuFind configuration + * + * @return void + */ + public function setConfig($config) + { // DEBUGGER if (!$config->System->debug == false) { $writer = new Writer\Stream('php://output'); @@ -215,4 +229,27 @@ class Logger extends BaseLogger { return $this->debugNeeded; } + + /** + * Set the service locator. + * + * @param ServiceLocatorInterface $serviceLocator Locator to register + * + * @return Logger + */ + public function setServiceLocator(ServiceLocatorInterface $serviceLocator) + { + $this->serviceLocator = $serviceLocator; + return $this; + } + + /** + * Get the service locator. + * + * @return \Zend\ServiceManager\ServiceLocatorInterface + */ + public function getServiceLocator() + { + return $this->serviceLocator; + } }