View Source

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

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

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

<li>Array arguments get flattened when creating Zend\Log\Logger <a href="">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>


<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 &quot;filter&quot; 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>


<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());