procmail
[Top] [All Lists]

Re: Procmail Question on more than one log file.

1998-04-03 00:18:18
|Thu 98-04-02 Shawn Boone <shboone(_at_)primenet(_dot_)com> list.procmail
|
| LOGFILE="/user/s/log/.logfile.pr`date +%d-%m-%y`"

Tip1: there is 20 times more effifient way yo get the date 
Tip2: The X-info leads your way to the source...

Ok. so I would write it like this:

    PMSRC       = ...your procmail script directory
    RC_DATE     = $PMSRC/pm-jadate.rc

    MY_LOGBASE  = "/user/s/log/.logfile.pr"
    ...whatever


    INCLUDERC   = $RC_DATE
    LOGFILE     = "$MY_LOGBASE.$YYYY-$MM-$DD"   # See rc_date

| I also use RC files as well.
| I would like to know how I can have it log everything to the first LOGFILE
| but when it hits a RC file to set it up so I can have it log to a new
| LOGFILE just for that mail

the idea is that you have to save the contents of a previous value.

    LOGFILE_    = $LOGFILE
    LOGFILE     = ..some new name

    ...call INCLUDERC or recipes in between

    LOGFILE     = $LOGFILE_     # restore saved.

But that's not good if the includerc you called would also redirect logfile.
And you wouldn't know if it happened to use/clash-with name LOGFILE_ ,
unless you examined all the RCs below.

The universal saving mechanism relies on keeping variables in "name space",
that is, if some procmail module changes the procmail variables, it must
save them as

    VARIABLE_namespace
    namespace_VARIABLE

or by using any other siilar variation on the theme. Hm, I must go and
check my modules and make sure I have used this consistently. So the
above more generally:

    [if this is .procmailrc]
  
    LOGFILE_procmailrc  = $LOGFILE          # save-1
    LOGFILE             = ...               # redirect-1

    INCLUDERC = [call it pm-xxx.rc]
        
        [inside  pm-xxx.rc]
            
        LOGFILE_pm_xxx = $LOGFILE           # save-2
        LOGFILE        = ...again new name  # redirect-2
        ...
        LOGFILE        = $LOGFILE_pm_xxx    # save-2-restore
        ...
        [pm-xxx.rc ends]

    LOGFILE     = $LOGFILE_procmailrc      # save-1-restore (toplevel)

So there, I think we got new section to pm-tips.txt :-) 
The abraction was a simple programming onion:

    save-1
    redirect-1

        save-2 
        redirect-2
        save-2-restore

    save-1-restore


jari

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