a | b/logger.py | ||
---|---|---|---|
1 | import sys |
||
2 | |||
3 | |||
4 | class Logger(object): |
||
5 | def __init__(self, path): |
||
6 | self.terminal = sys.stdout |
||
7 | self.log = open(path, 'a') |
||
8 | |||
9 | def write(self, message): |
||
10 | self.terminal.write(message) |
||
11 | self.log.write(message) |
||
12 | |||
13 | def flush(self): |
||
14 | # needed for python 3 compatibility |
||
15 | pass |