def start(filename, debugLevel=2, suppress_motion_events=True, logger_comments=True): global _suppress_motion_events logutils.set_debugLevel(debugLevel) _suppress_motion_events = suppress_motion_events if logutils.recording(): #print "gtklogger already recording." logutils.logfile().close() #else: #print "gtklogger recording starting." try: if logger_comments == True: # Open a pipe to the loggergui process for inserting # comments into the output stream. guifile = os.path.abspath(loggergui.__file__) # The third argument of '1' to popen indicates that the # stream is line buffered. This ensures that the comments # appear in the right place. ## TODO 3.1: os.popen is deprecated. Use subprocess.Popen. process = os.popen("python " + guifile + " " + filename, "w", 1) logutils.set_logfile(process) elif type(filename) is types.StringType: logutils.set_logfile(open(filename, "w")) else: # filename is assumed to be a file logutils.set_logfile(filename) except: logutils.set_logfile(None) raise
def stop(): if logutils.recording(): try: print "gtklogger recording stopping." logutils.logfile().close() finally: logutils.set_logfile(None)
def start(filename, debugLevel=2, suppress_motion_events=True, logger_comments=True): global _suppress_motion_events logutils.set_debugLevel(debugLevel) _suppress_motion_events = suppress_motion_events if logutils.recording(): logutils.logfile().close() try: if logger_comments: # Open a pipe to the loggergui process for inserting # comments into the output stream. from GUI import loggergui guifile = os.path.abspath(loggergui.__file__) # The third argument of '1' to popen indicates that the # stream is line buffered. This ensures that the comments # appear in the right place. ## TODO: os.popen is deprecated. Use subprocess.Popen. process = os.popen("python " + guifile + " " + filename, "w", 1) logutils.set_logfile(process) elif type(filename) is types.StringType: logutils.set_logfile(open(filename, "w")) else: # filename is assumed to be a file logutils.set_logfile(filename) except: logutils.set_logfile(None) raise
def _writeline(line): global _prevline if line != _prevline or _not_redundant(line): print >> logutils.logfile(), line logutils.logfile().flush() if logutils.debugLevel() >= 2 and not logutils.replaying(): print >> sys.stderr, "//////", line _prevline = line
def checkpoint(comment): _checkpointlock.acquire() try: if logutils.recording(): # recording print >> logutils.logfile(), "checkpoint", comment logutils.logfile().flush() if logutils.debugLevel() >= 2: print >> sys.stderr, "////// checkpoint", comment if logutils.replaying(): try: _checkpointdict[comment] += 1 except KeyError: _checkpointdict[comment] = 1 finally: _checkpointlock.release()
def checkpoint(comment): _checkpointlock.acquire() try: #print "checkpoint access attempt: %s" %comment if logutils.recording(): # recording # print "checkpoint accessed for recording: %s" %comment print >> logutils.logfile(), "checkpoint", comment if logutils.debugLevel() >= 2: print >> sys.stderr, "////// checkpoint", comment if logutils.replaying(): try: _checkpointdict[comment] += 1 #print "checkpoint accessed for replaying: %s" %comment except KeyError: _checkpointdict[comment] = 1 #print "checkpoint fail to be played: %s" %comment #if not logutils.replaying() and not logutils.recording(): #print "checkpoint access failed: %s" %comment finally: _checkpointlock.release()
def stop(): if logutils.recording(): try: logutils.logfile().close() finally: logutils.set_logfile(None)