Why don't you place the log in the registry? You're able to get it everywhere you want.
Inside bootstrap resource:
Zend_Registry::set('log', $log);
Where you want to log something:
Zend_Registry::get('log')->warn('Your log message here');
Regards, Jurian
--
Jurian Sluiman
Soflomo.com
Op Monday 12 October 2009 08:51:21 schreef Michael Depetrillo:
> <?php
> class Zend_Application_Bootstrap_Resource_Logger extends
> Zend_Application_Resource_ResourceAbstract
> {
> /**
> * @var Zend_Layout
> */
> protected $_logger;
>
> /**
> * Defined by Zend_Application_Resource_Resource
> *
> * @return Zend_Logger
> */
> public function init()
> {
> $this->getBootstrap()->bootstrap('FrontController');
> return $this->getLogger();
> }
>
> /**
> * Retrieve logger object using resources.logger.applog configuration
> value.
> * Will also set php error_log if resources.logger.errorlog
> configuration value provided.
> * @return Zend_Logger
> */
> public function getLogger($name = 'applog')
> {
> if (null === $this->_logger) {
> $options = $this->getOptions();
>
> if (!isset($options[$name])) {
> throw new Exception("Log path undefined in
> application.ini");
> }
>
> if (isset($options['errorlog'])) {
> ini_set('error_log', $options['errorlog']); // send php
> errors here
> ini_set('log_errors', 1);
> }
>
> $writer = new Zend_Log_Writer_Stream($options[$name]);
> $this->_logger = new Zend_Log($writer);
> }
> return $this->_logger;
> }
>
> }
>
> Michael DePetrillo
> [email protected]
> Mobile: (858) 761-1605
> www.michaeldepetrillo.com
>
> On Sun, Oct 11, 2009 at 12:53 AM, Peter Smit <[email protected]> wrote:
> > I would like to make a global Zend_Log object that I can reach from my
> > Controllers and my Models.
> >
> > What should I add to my Bootstrap? (My bootstrap extends
> > Zend_Application_Bootstrap)
> >
> > How then can I reach the logger object from my controller actions and
> > from my model?
> > Regards,
> >
> > Peter Smit
signature.asc
Description: This is a digitally signed message part.
