def log(self, request, response=None): """add data to log along with time, sequence, hash, and other metadata""" reqSha = toolbox.sha1sum(request) respSha = toolbox.sha1sum(str(response)) self.logs.append((len(self.logs), toolbox.time(), reqSha, respSha, request, response)) if self.verbose: print "sha1(REQUEST): %s\tsha1(RESPONSE): %s" % (reqSha, respSha)
def logFileSetup(self, baseLogDir): """ create file/directory structure for logs, do this once """ self.logPath = os.path.join(baseLogDir, toolbox.time()) os.makedirs(self.logPath) self.metaLogPath = os.path.join(self.logPath, self.metaLogFileName) # write header to metaLogFile metaLogFile = open(self.metaLogPath, "w") metaLogFile.write("%s\t%s\t\t%s\t\t%s\n" % ("Run", "Time", "sha1sum(Request)", "sha1sum(Response)")) metaLogFile.close()
def logFileSetup(self, baseLogDir): """ create file/directory structure for logs, do this once """ self.logPath = os.path.join(baseLogDir, toolbox.time()) os.makedirs(self.logPath) self.metaLogPath = os.path.join(self.logPath, self.metaLogFileName) # write header to metaLogFile metaLogFile = open(self.metaLogPath, "w") metaLogFile.write( "%s\t%s\t\t%s\t\t%s\n" % ("Run", "Time", "sha1sum(Request)", "sha1sum(Response)")) metaLogFile.close()