You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

logger2file.py 624 B

5 years ago
123456789101112131415161718192021222324252627
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. Created on Fri Nov 8 14:21:25 2019
  5. @author: ljia
  6. """
  7. import sys
  8. import time
  9. class Logger(object):
  10. def __init__(self):
  11. self.terminal = sys.stdout
  12. self.log = open("log." + str(time.time()) + ".log", "a")
  13. def write(self, message):
  14. self.terminal.write(message)
  15. self.log.write(message)
  16. def flush(self):
  17. #this flush method is needed for python 3 compatibility.
  18. #this handles the flush command by doing nothing.
  19. #you might want to specify some extra behavior here.
  20. pass
  21. sys.stdout = Logger()

A Python package for graph kernels, graph edit distances and graph pre-image problem.