Skip to content
Snippets Groups Projects
Commit bb51dadd authored by Demian Katz's avatar Demian Katz
Browse files

Adjusted logger to have configuration injected rather than pulled from...

Adjusted logger to have configuration injected rather than pulled from ConfigReader; added comments; implemented ServiceLocatorAwareInterface in anticipation of future changes.
parent d29bc5ff
No related merge requests found
......@@ -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',
......
......@@ -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;
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment