On 2015-11-13 14:23:03, alvin@netvel.net wrote:
Show quoted text> With the following config:
>
> Mail-Log-Trace-1.0101
> perl v5.20.3
> Linux 4.2.5-201.fc22.x86_64
>
>
> If I do a $tracer->find_message_info({to_address =>
> '<nobody@nodomain.com>'})
> multiple times I get "Connection start predates logfile".
>
> On a reasonably busy mail server your going to always get transactions
> that overlap the edge of the log file.
>
> I sort of expect that I should be able to use the following code to
> print data from the log file.
>
> while( $tracer->find_message_info({to_address => '<nobody@nodomain.com>'}))
> {
> my $from_address = $tracer->get_from_address();
> my $mid = $tracer->get_message_id();
> $tracer->clear_message_info();
> print "$from_address,$mid\n";
> }
That exception is expected - Mail::Log::Trace tries to gather all the info on a message, so if it can't it needs to tell you why. You can catch the exception and get all the info it was able to collect from $tracer. (Ideally, handling the fact that some of it will be undefined along the way.) You should then be able to go to the next loop iteration and get the next message's info.
If that loop always gets the same message info, that's a bug, and I'll need to look at it. But after a few exceptions, it should run through to the end of the file. (Possibly giving some more exceptions at the end of the file.)
The point of this is so that you can handle transactions that overlap the log file correctly - if this module didn't throw any type of exception you'd just get the transaction twice (once for the 'first' log file, and once for the 'second'), both with several undefined values. This way you know which messages need special handling.
It's likely that I need to write more documentation, of what errors this module can throw under different circumstances.
(Note that my original use case for this module was to parse ~9GB of logs a day... I'm aware how it operates on a busy server. Though my end analysis was 'to slow for production'.)