procmail
[Top] [All Lists]

Re: Include message-id in log

2001-10-28 15:33:45
On Sat, 27 Oct 2001, Harry Putnam wrote:

I've written some scripting that depends on that Message-ID being
where you see it.  Scripting that extracts certain info from the log.

Until I started writing this script I hadn't noticed that at least
certain recipe do not get this treatment.  So the log has hundreds
of entries where there is no Message-ID supplied.

The main culprit is a recipe that feeds  a simple backup system

    :0 c
    backup/.
Writes a dup of all incoming in MH format to ~/spool/backup/.  I
suspect it is the `c' flag that causes the different behavior
concerning  recording the Message-ID:  Log output for this recipe
looks like the example below.  You'll notice the backup part never
assigns an EXITCODE=0 which seem likely to be related too.

If procmail never closes there then the TRAP doesn' execute maybe?

That's exactly what's happening.  The "c" means that procmail is making a
copy of the message; the TRAP won't execute until the "final" delivery.
The message-id is getting logged, although it's only logged once per
message.  Why isn't that enough?

You can try this:

:0 c
{
 :0
 backup/.
}

When the "c" flag appears before a block, procmail forks.  In this case
the TRAP will be executed when each procmail process finishes.

However, I don't think there's any guarantee in that case that the two
processes write serially to the log file -- that is, you might get
From/Subject/Folder from one process, then From/Subject/Folder from the
other, and then Message-Id from one, and then Message-Id from the other --
so you might have to employ an additional lock file to assure that the
output looks like what you want.  Someone will certainly correct me on
this if I'm wrong.

As for where one entry ends and the next begins: The line with the `date`
output will always be the first one resulting from any message delivery.
You probably should be using

LOG="`date`
"

to force a newline into the log following the output of `date`.

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>