Created
May 19, 2010 17:12
-
-
Save stevelounsbury/406559 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * ZF Controller Action helper for logging. Assumes you have the log resource | |
| * setup in your bootstrap, but silently fails if it is not found. | |
| */ | |
| class My_Action_Helper_Log extends Zend_Controller_Action_Helper_Abstract | |
| { | |
| /** | |
| * @var Zend_Log | |
| */ | |
| protected $_log = null; | |
| public function init() | |
| { | |
| $this->_log = $this->getActionController() | |
| ->getInvokeArg('bootstrap') | |
| ->getResource('log'); | |
| } | |
| public function log($message, $level = Zend_Log::DEBUG) | |
| { | |
| if ($this->_log == null) { | |
| return; | |
| } | |
| return $this->_log->log($message, $level); | |
| } | |
| public function __call($name, $arguments) | |
| { | |
| if ($this->_log == null) { | |
| return; | |
| } | |
| return $this->_log->__call($name, $arguments); | |
| } | |
| } |
Author
Good god that's some hot zend action right there.
I honestly tend to prefer putting logging in a fat model layer and keeping my controllers thin.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hmm, is calling __call directly on $this->_log evil?