From 905e1957927b1a5d634e2f8009e9d7f9251a4ba3 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Thu, 13 Sep 2012 15:26:10 -0400 Subject: [PATCH] Load logger through service manager. --- module/VuFind/config/module.config.php | 5 +++-- module/VuFind/src/VuFind/Connection/Manager.php | 2 +- .../src/VuFind/Controller/CoverController.php | 2 +- module/VuFind/src/VuFind/Log/Logger.php | 14 -------------- module/VuFind/src/VuFind/Search/Summon/Results.php | 2 +- 5 files changed, 6 insertions(+), 19 deletions(-) diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php index c7bfedd3572..e5c6587744b 100644 --- a/module/VuFind/config/module.config.php +++ b/module/VuFind/config/module.config.php @@ -262,12 +262,12 @@ $config = array( 'factories' => array( 'worldcatconnection' => function ($sm) { $wc = new \VuFind\Connection\WorldCat(); - $wc->setLogger(\VuFind\Log\Logger::getInstance()); + $wc->setLogger($sm->get('Logger')); return $wc; }, 'worldcatutils' => function ($sm) { $wcu = new \VuFind\Connection\WorldCatUtils(); - $wcu->setLogger(\VuFind\Log\Logger::getInstance()); + $wcu->setLogger($sm->get('Logger')); return $wcu; }, ), @@ -275,6 +275,7 @@ $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/Connection/Manager.php b/module/VuFind/src/VuFind/Connection/Manager.php index 9153f35ee07..477e1d9afa6 100644 --- a/module/VuFind/src/VuFind/Connection/Manager.php +++ b/module/VuFind/src/VuFind/Connection/Manager.php @@ -117,7 +117,7 @@ class Manager $index->setServiceLocator(self::$serviceLocator); // Set the logger: - $index->setLogger(\VuFind\Log\Logger::getInstance()); + $index->setLogger(self::$serviceLocator->get('Logger')); return $index; } diff --git a/module/VuFind/src/VuFind/Controller/CoverController.php b/module/VuFind/src/VuFind/Controller/CoverController.php index 3eb71a792bf..bc41c8a6e93 100644 --- a/module/VuFind/src/VuFind/Controller/CoverController.php +++ b/module/VuFind/src/VuFind/Controller/CoverController.php @@ -54,7 +54,7 @@ class CoverController extends AbstractBase ConfigReader::getConfig(), $this->getServiceLocator()->get('CacheManager')->getCacheDir() ); - $this->loader->setLogger(\VuFind\Log\Logger::getInstance()); + $this->loader->setLogger($this->getServiceLocator()->get('Logger')); } return $this->loader; } diff --git a/module/VuFind/src/VuFind/Log/Logger.php b/module/VuFind/src/VuFind/Log/Logger.php index 6b472a36450..a9db538efa8 100644 --- a/module/VuFind/src/VuFind/Log/Logger.php +++ b/module/VuFind/src/VuFind/Log/Logger.php @@ -204,20 +204,6 @@ class Logger extends BaseLogger } } - /** - * Get the logger instance. - * - * @return Logger - */ - public static function getInstance() - { - static $instance; - if (!$instance) { - $instance = new Logger(); - } - return $instance; - } - /** * Is one of the log writers listening for debug messages? (This is useful to * know, since some code can save time that would be otherwise wasted generating diff --git a/module/VuFind/src/VuFind/Search/Summon/Results.php b/module/VuFind/src/VuFind/Search/Summon/Results.php index 9441aca8804..c9f37078256 100644 --- a/module/VuFind/src/VuFind/Search/Summon/Results.php +++ b/module/VuFind/src/VuFind/Search/Summon/Results.php @@ -60,7 +60,7 @@ class Results extends BaseResults $id = isset($config->Summon->apiId) ? $config->Summon->apiId : null; $key = isset($config->Summon->apiKey) ? $config->Summon->apiKey : null; $conn = new SummonConnection($id, $key); - $conn->setLogger(\VuFind\Log\Logger::getInstance()); + $conn->setLogger($this->getServiceLocator()->get('Logger')); } return $conn; } -- GitLab