File locking and logging

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kamus of Kadizhar

    #1

    File locking and logging

    Thanks to Robert Brewer, I got enough insight into logging to make it work....

    Now I have another issue: file locking. Sorry if this is a very basic
    question, but I can't find a handy reference anywhere that mentions this.

    When a logger opens a log file for append, is it automatically locked so
    other processes cannot write to it? And what happens if two or more
    processes attempt to log an event at the same time?

    Here's my situation. I have two or three workstations that will log an
    event (the playing of a movie). The log file is NFS mounted and all
    workstations will use the same log file. How is file locking implemented?
    Or is it?

    I've read through the various logger doc pages and this is never mentioned.

    The logging code that works (for me at least) is this:

    logging.basicCo nfig()
    logFile = logging.handler s.RotatingFileH andler("/var/log/user/movies.log",'a' ,2000,4)
    logFile.setLeve l(logging.INFO)
    formatter = logging.Formatt er(hostname + ' %(asctime)s %(message)s',da tefmt='%Y-%m-%d.%H:%M')
    logFile.setForm atter(formatter )
    logging.getLogg er('').addHandl er(logFile)
    logging.warning (movieName)
    logFile.flush()
    logFile.close()

    Any thoughts are appreciated....

    Thanks,

    --Kamus

    --
    o |
    o__ >[] | A roadie who doesn't ride a mountain bike has no soul.
    ,>/'_ /\ | But then a mountain biker who doesn't ride a road bike has no legs...
    (_)\(_) \ \ | -Doug Taylor, alt.mountain-bike

Working...