X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fdaklog.py;h=a698cbc53fc5d754fb3ec2392aab73b299c3e1eb;hb=391f5ec09a119131dc846b796ca791f4cecc69e4;hp=05ca9b1adaab9770ae6048956b1df1fda00a5e13;hpb=e2c4fd7f21c3b33cd7192bded5d6373e0ee90374;p=dak.git diff --git a/daklib/daklog.py b/daklib/daklog.py index 05ca9b1a..a698cbc5 100644 --- a/daklib/daklog.py +++ b/daklib/daklog.py @@ -24,6 +24,7 @@ Logging functions ################################################################################ +import fcntl import os import pwd import time @@ -80,13 +81,14 @@ class Logger(object): details.insert(0, timestamp) # Force the contents of the list to be string.join-able details = [ str(i) for i in details ] + fcntl.lockf(self.logfile, fcntl.LOCK_EX) # Write out the log in TSV self.logfile.write("|".join(details)+'\n') # Flush the output to enable tail-ing self.logfile.flush() + fcntl.lockf(self.logfile, fcntl.LOCK_UN) def close (self): "Close a Logger object" self.log(["program end"]) - self.logfile.flush() self.logfile.close()