Skip to end of metadata
Go to start of metadata

<h2>Feedbacks/issues of Zend_Log for ZF1</h2>

<ul>
<li>More flexible mapping ror Zend_Log_Writer_Db <a href="http://framework.zend.com/issues/browse/ZF-2658">ZF-2658 </a></li>
<li>Zend_Log_Formatter_Simple must print %info% event <a href="http://framework.zend.com/issues/browse/ZF-10427">ZF-10427 </a></li>
<li>Incorrect handling of E_DEPRECATED and E_USER_DEPRECATED <a href="http://framework.zend.com/issues/browse/ZF-12031">ZF-12031 </a></li>
<li>Patch to make line and file information available in log events <a href="http://framework.zend.com/issues/browse/ZF-2428">ZF-2428 </a></li>
<li>Add Zend_Log::getWriters() to return list of attached writers <a href="http://framework.zend.com/issues/browse/ZF-3581">ZF-3581 </a></li>
<li>Create the log file only if there is something to log <a href="http://framework.zend.com/issues/browse/ZF-5741">ZF-5741 </a></li>
<li>Add callback support for log events <a href="http://framework.zend.com/issues/browse/ZF-7959">ZF-7959 </a></li>
<li>Filtering messages which are not strings <a href="http://framework.zend.com/issues/browse/ZF-5778">ZF-5778 </a></li>
<li>Methods to remove log writers, filters and event items. <a href="http://framework.zend.com/issues/browse/ZF-1833">ZF-1833 </a></li>
</ul>

<h2>Feddbacks/issues of Zend\Log for ZF2</h2>

<ul>
<li>Array arguments get flattened when creating Zend\Log\Logger <a href="http://framework.zend.com/issues/browse/ZF2-34">ZF2-34 </a></li>
<li>Reflection is used in Zend_Log::__construct() to build priorities name (slow)</li>
<li>Magic method __call() used for shortcut log an event (slow, and hard to discover API)</li>
<li>Bad design for Zend_Log::factory() (it calls others factories of writer/formatter/filter defined in config)</li>
</ul>

<h2>Proposals</h2>

<ul>
<li>API discoverable (emerg, alert, crit, err, warn, notice, info, debug)</li>
<li>Improve Simple Formatter (according to the feedbacks/issues)</li>
<li>Use the plugin broker to review factory (Zend\Loader\Broker, Zend\Loader\Pluggable)</li>
<li>Use of SplPriorityQueue to manage multiple writers (with priorities)</li>
<li>New formatter (json)</li>
<li>Add a Zend\Log\Filter\Validator to use a Zend\Validator object like "filter" for the log message</li>
<li>Create LoggerAware for Di</li>
<li>Renderer for exceptions, array, string object, event, etc (format exception instead of __toString())</li>
<li>Modify parameters of Logger::log($priority, $message, $extras)</li>
<li>Rename Filter\Message in Filter\StringMatch or Filter\Regex</li>
</ul>

<h2>Usage</h2>

<ac:macro ac:name="code"><ac:plain-text-body><![CDATA[
$logger = new Logger;
// You can attach a filter to exclude records with a priority lower than warning
$logger->addFilter(new Filter\Priority(Logger::WARN));
// Output is configured for console
$logger->addWriter(new Writer\Stream('php://stdout'));

// Default format displays datetime, priority name, and message
$logger->info(sprintf('User "%s" is successfully authenticated', $user->getLogin()));

// You can use a class who implements __toString() as message and array for extra informations
$logger->error(new RuntimeException('Could not create the order'), $request()>post()>toArray());
]]></ac:plain-text-body></ac:macro>

Labels:
zf2 zf2 Delete
zend_log zend_log Delete
logging logging Delete
rfc rfc Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Nov 15, 2011

    <p>There were a few features discussed in IRC and also in ZF1 that I'm not sure are addressed.</p>

    <p>In ZF1, you could have multiple writers. Each writer could indicate which priorities it was interested in, as well as filter on messages to determine interest. Will that behaviour still exist?</p>

    <p>There were folks asking on IRC if individual writers could be instantiated standalone, and/or attached to a logger instance and retrieved by name, so as to allow logging directly to a specific writer.</p>

    <p>Regarding custom priorities, I think we already can support it, if the main method is "log($message, $priority, $extras)". The question is if the priority provided needs to have a string representation, in which case having some sort of priority map may be interesting.</p>

    <p>Over all, however, the direction looks fine for starting development.</p>