So I read up and then I created this function in my Bootstrap.php
public function _initLog()
{
$resource = $this->getPluginResource('db');
$db = $resource->getDbAdapter();
$columnMapping = array('lvl' => 'priority', 'msg' => 'message');
$writer = new Zend_Log_Writer_Db($db, 'log', $columnMapping);
$logger = new Zend_Log($writer);
$logger->warn('Logger Init');
return $logger;
}
I see the "Logger Init" in my Log Table so I know this is firing correctly.
So I moved on to my Action Controller and put
$logger = $this->getInvokeArg('bootstrap')->getResource('logger');
Which results in:
Fatal error: Call to a member function getResource() on a non-object in
/sites/performance/performance-api/application/controllers/XmlController.php
on line 25
Line 25 is $logger =
$this->getInvokeArg('bootstrap')->getResource('logger');
Do I have to create Resource Plugins for everything or am I missing
something to place $logger as a resource?
Here is my Bootstrap.php
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
public function run()
{
Zend_Registry::set('config', $this->getOptions());
Zend_Registry::set('env', APPLICATION_ENV);
$this->frontController->dispatch();
}
public function _initLog()
{
$resource = $this->getPluginResource('db');
$db = $resource->getDbAdapter();
$columnMapping = array('lvl' => 'priority', 'msg' => 'message');
$writer = new Zend_Log_Writer_Db($db, 'log', $columnMapping);
$logger = new Zend_Log($writer);
//$logger->warn('Logger Init');
return $logger;
}
protected function _initAutoload()
{
$moduleLoader = new Zend_Application_Module_Autoloader(array(
'namespace' => '',
'basePath' => APPLICATION_PATH));
return $moduleLoader;
}
}
Thx
--
View this message in context:
http://www.nabble.com/Zend_Application_Bootstrap_Bootstrap--and-Zend_Log-tp23915940p23937424.html
Sent from the Zend Framework mailing list archive at Nabble.com.