SHARE
TWEET

Untitled

a guest Feb 28th, 2013 12 Never
  1. class Logger:
  2.         def __init__(self, log_path):
  3.             self.terminal = sys.stdout
  4.             self.log = open(log_path, "a")
  5.  
  6.         def write(self, message):
  7.             self.terminal.write(message)
  8.             self.log.write(message.encode("utf-8"))
  9.  
  10.     sys.stdout = Logger(log_path)
  11.     sys.stderr = Logger(log_path)
RAW Paste Data
Top