@cryptotaxi247 / netdata-1 / commits / 8c5fe2f59

return empty list if log file hasn't changed.

paulfantom committed Jul 23, 2016 at 21:51 UTC 8c5fe2f5993ac0c78169fecb6b65dc9a9cefc315
1 file changed +3 -2
python.d/python_modules/base.py
+3 -2
@@ -681,10 +681,10 @@ class LogService(SimpleService):
681 lines = []
682 try:
683 if os.path.getsize(self.log_path) < self._last_position:
684 - self._last_position = 0
684 + self._last_position = 0 # read from beginning if file has shrunk
685 elif os.path.getsize(self.log_path) == self._last_position:
686 self.debug("Log file hasn't changed. No new data.")
687 - return False
687 + return [] # return empty list if nothing has changed
688 with open(self.log_path, "r") as fp:
689 fp.seek(self._last_position)
690 for i, line in enumerate(fp):
@@ -720,6 +720,7 @@ class LogService(SimpleService):
720 return False
721
722 def create(self):
723 + # set cursor at last byte of log file
724 self._last_position = os.path.getsize(self.log_path)
725 status = SimpleService.create(self)
726 # self._last_position = 0