E.5.1 Logfile-Klasse
import c_bsio
class c_log(c_bsio.c_bsio):
def __init__(self,pname,fname):
import posix
c_bsio.c_bsio.__init__(self,fname,"a+")
self.trailer=pname+" ("+str(posix.getpid())+"): "
self.open()
def __del__(self):
self.close()
def log(self,line):
self.write(self.trailer+line+"\n")
self.fd.flush()