9 def __init__(self, f, overwrite = 0, timeformat = "%a %d %b %Y %T"):
10 if type(f) == type(''): # If f is string - use it as file's name
15 self.outfile = open(f, mode)
17 self.outfile = f # else assume it is opened file (fileobject) or
18 # "compatible" object (must has write() method)
20 self.timeformat = timeformat
28 if type(self.f) == type(''): # If f was opened - close it
33 self.outfile.write("%s %s\n" % (strftime(self.timeformat, localtime(time())), str))
52 log = makelog("test.log")
57 if __name__ == "__main__":