procmail
[Top] [All Lists]

Re: turning on logging

2001-08-22 21:23:46
On 22 Aug, mulligan(_at_)mulligan(_dot_)com wrote:
| Is there a way to turn on logging inside a recipe. [...]

Yes. Assuming you mean this literally, i.e. you have no LOGFILE defined
and are doing no other logging, something like:

:0
* condition(s)
{
  LOGFILE=/path/to/your/logfile
  :0
  $DEFAULT  # or whatever else you do with it
}
LOGFILE

By itself, this won't get you anything, but you don't specify what it
is you want to log. Unless there's an error, this won't get you anything
without adding one or more of VERBOSE=yes, LOGABSTRACT=yes, or LOG="your
log entry here".

You really should always have a LOGFILE defined from the top of your
rcfile. If you want VERBOSE=no and LOGABSTRACT=no that's fine, then all
you'll get is errors, but I respectfully suggest you want to see those
at an absolute minimum.

My guess is you want to make a specific log entry for this one recipe.
Let's assume you've seen the light and defined a LOGFILE near the top
of your rcfile. In that case, you'd do something like:

NL="
"     # because procmail doesn't automatically append one
:0
* ^From .*\<\/(S(un|at)|Mon|T(ue|hu)|Wed|Fri)\>.*
* ^From:.*\<gwb(_at_)whitehouse(_dot_)gov\>
{
   LOG="I got mail from gwb(_at_)whitehouse(_dot_)gov on $MATCH$NL"
   :0
   $DEFAULT
}

Everything after the \/ token in the first condition is assigned to the
$MATCH variable, so you'd get an entry in your log like:

I got mail from gwb(_at_)whitehouse(_dot_)gov on Wed Aug 22 23:42:03 2001

That is assuming the envelope "From " line hasn't disappeared and it is
in typical format, otherwise neither condition will match, but you get
the idea.

-- 
                   /"\
Don Hammond        \ /     ASCII Ribbon Campaign
Raleigh, NC US      X        Against HTML Mail,
                   / \      and News Too

_______________________________________________
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>