You actually can, from Mage.php
$writerModel = (string)self::getConfig()->getNode('global/log/core/writer_model');
So create a custom module, extend Zend_Log_Writer_Stream
and add the next lines to your config.xml
<global>
<log>
<core>
<writer_model>Company_Module_Model_Log_Stream</writer_model>
</core>
</log>
</global>
The method ->write($message)
is called. You could add your filter here.
You could something like:
/**
* @var string
*/
protected $_lastMessage;
/**
* @var int
*/
protected $_messageCounter;
/**
* Write a message to the log.
*
* @param array $event event data
* @return void
* @throws Zend_Log_Exception
*/
protected function _write($event)
{
$line = $this->_formatter->format($event);
if ($this->_lastMessage == $line) {
// Same line, do nothing, stop flooding
$this->_messageCounter++;
return;
} else {
// Check if a notice for repeated message should be added
if ($this->_messageCounter > 1 && $this->_lastMessage) {
if (false === @fwrite($this->_stream, sprintf("Last message repeated %s times", $this->_messageCounter))) {
throw new Zend_Log_Exception("Unable to write to stream");
}
}
// Update counter and last message
$this->_lastMessage = $line;
$this->_messageCounter = 1;
}
if (false === @fwrite($this->_stream, $line)) {
#require_once 'Zend/Log/Exception.php';
throw new Zend_Log_Exception("Unable to write to stream");
}
}
This way you keep your core code clean.