Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 28th, 2013  |  syntax: Python  |  size: 0.33 KB  |  views: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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)
clone this paste RAW Paste Data