ZF-9876: Override maximum_log in Zend_Mail_Protocol_Abstract
Description
In my app, I want to log the whole SMTP transaction. To do so, I'm using: {quote} $tr->getConnection()->getLog() {/quote}
This works and provides me with the SMTP transaction, however.. its length is limited. Upon further investigation there is an hard coded value MAXIMUM_LOG in Zend_Mail_Protocol_Abstract.
I've (temporarily) modified this from 64 to 4096 so it covers the whole transaction.In my app I remove everything between DATA and the trailing .
Can there be a setter (and getter) to modify this limit?
Comments
Posted by Frank (sypher) on 2010-05-27T09:43:28.000+0000
Maybe its also possible to add an option to disable the limit/checking of the limit. Setting it to 999999 isn't very pretty.
Posted by Josh Boyd (boydjd) on 2010-06-09T14:14:54.000+0000
Patch attached.
Posted by Satoru Yoshida (satoruyoshida) on 2010-06-12T06:28:58.000+0000
Sorry, I have been inactive since last April.
Posted by Dolf Schimmel (Freeaqingme) (freak) on 2010-06-12T10:00:00.000+0000
I will review the patch this week and commit it if okay.
Posted by Frank (sypher) on 2010-06-23T13:10:01.000+0000
Dolf, I hope you haven't forgot about this? :)
Posted by Michael Kliewe (mkliewe) on 2010-07-15T11:35:20.000+0000
I would also love to see a change here because I have the problem that I want to send a mail with attachments >100MB, and my php memory limit of 512 MB is exhausted, I think this log is one of the problems. I would like to disable logging completly, setting MAXIMUM_LOG to 0 is not enough because the big DATA request would be logged anyway into $this->_log and fill up my memory.
Posted by Michael Kliewe (mkliewe) on 2010-07-15T11:55:38.000+0000
Forget the sentence with the big DATA request, I have seen that there are thousands of little log entries instead of one big log entry when sending a big mail.
But I would like to disable this log per default because 99% of the users don't need it, it only wastes CPU. If a developer needs the log he can enable it then, but default should be off. Or default of $_maximumLog should be -1 which disable the log. In _addLog there has to be one line
Posted by Dolf Schimmel (Freeaqingme) (freak) on 2010-07-16T15:05:57.000+0000
Resolved on trunk and will be released in the next major release.
Please beware that I'm unsure why originally it was chosen to use a constant for this. If it turns out there was a proper reason for that that's still legit this patch will be reverted.
In any case; thank you for reporting this issues and my apologies for the delays in fixing it.
Posted by Josh Boyd (boydjd) on 2010-07-16T15:34:25.000+0000
Your commit is wrong, getMaximumLog is incorrectly named setMaximumLog.
Posted by Dolf Schimmel (Freeaqingme) (freak) on 2010-07-16T15:38:08.000+0000
Should be fixed once again. Thanks.
Posted by Michael Kliewe (mkliewe) on 2010-07-20T08:13:53.000+0000
I checked your commit, Dolf, and I cannot see a possibility to disable the log. Should I create a new issue for that?
Because I don't want to log the transaction in production environment, and logging every line is a performance problem, because in my tests when sending a 60MB mail I have 300.000 calls of _addLog and also 300.000 calls of
// Save request to internal log if (true == $this->_loggingEnabled) { $this->_addLog($request . self::EOL); }``` in both _send() and _receive() so we don't have thousands of function calls.
Perhaps in ZF 2.0 we could even disable this logging feature by default because only developers need it for debugging, 99% of the users don't need that logging feature in a default installation. This would increase the performance of the component. But this would be a BC.
Posted by Josh Boyd (boydjd) on 2010-07-20T08:40:40.000+0000
Just call setMaximumLog(0) and logging is disabled.
Posted by Michael Kliewe (mkliewe) on 2010-07-20T10:16:27.000+0000
@Josh: I don't see it, could you please tell me the line? There is no "return" or something in _addLog(), so the function _addLog() is called every time and an entry is filled into the array $this->_log . You are right that this entry is shifted out on the next call of _addLog(), but it keeps filling the array 300.000 times.