import logging
import os
+import os.path
import sys
if stdout == None:
stdout = sys.stdout
self.stdout = stdout
- log_file = '%s_%d.log' % (self.__class__.__name__, os.getpid())
- logging.basicConfig(filename=log_file, level=log_level)
+ self.log_file = '%s_%d.log' % (self.__class__.__name__, os.getpid())
+ logging.basicConfig(filename=self.log_file, level=log_level)
self.log = logging
+ def cleanup_log(self):
+ self.log = None
+ if os.path.getsize(self.log_file) == 0:
+ os.remove(self.log_file)
+
def run(self):
state = self._initial_state()
while True:
self._process(tag, type, data, state)
except RunComplete:
break
+ self.cleanup_log()
def _parse(self, line):
self.log.debug('read: %s' % line)