-- Simon Walter <[email protected]> wrote
(on Wednesday, 27 April 2011, 05:05 PM +0900):
> I'm wondering why in the ErrorController.php file made by Zend_Tool we
> have this:
> 
> 
>         // Log exception, if logger available
>         if ($log = $this->getLog()) {
>             $log->crit($this->view->message, $errors->exception);
>         }
> 
> Does the Exception cast to a priority value? Wouldn't this or
> something similar depending on a verbosity switch make more sense:
> 
>         // Log exception, if logger available
>         if ($log = $this->getLog()) {
>             $log->crit($errors->exception);
>         }
> 
> If an Exception doesn't cast to a log priority value, then the
> original code is incorrect.  Either way, it's using the crit() method
> which will override(discard?) the priority value, no?
> 
> Minor, but I'm sure full logs will help more than the generic message
> sent to the view.
> 
> If it's a bug, I'll report it.

Not a bug; you're misinterpreting what the second argument does.

We already have a priority; we're calling the "virtual method" crit(),
which basically is calling log() with a Zend_Log::CRIT priority level.
What the second argument here does is pass context to the log writer.
Some log writers (e.g., Zend Server Monitor logger) will take this
information and associate it with the log message, allowing you to drill
down into the full exception.

So, what we're doing is:

 * Providing a message for the logger ($this->view->message)
 * Providing optional context for context-aware loggers (the exception
   itself)

We can't simply provide just the exception, as most loggers will not be
able to use it; they expect strings.

-- 
Matthew Weier O'Phinney
Project Lead            | [email protected]
Zend Framework          | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to