From: paulfantom Date: Sat, 23 Jul 2016 19:51:32 +0000 (+0200) Subject: return empty list if log file hasn't changed. X-Git-Tag: v1.3.0~40^2~4 X-Git-Url: https://arthur.barton.de/gitweb/?p=netdata.git;a=commitdiff_plain;h=8c5fe2f5993ac0c78169fecb6b65dc9a9cefc315 return empty list if log file hasn't changed. --- diff --git a/python.d/python_modules/base.py b/python.d/python_modules/base.py index e44edf5d..0918a30f 100644 --- a/python.d/python_modules/base.py +++ b/python.d/python_modules/base.py @@ -681,10 +681,10 @@ class LogService(SimpleService): lines = [] try: if os.path.getsize(self.log_path) < self._last_position: - self._last_position = 0 + self._last_position = 0 # read from beginning if file has shrunk elif os.path.getsize(self.log_path) == self._last_position: self.debug("Log file hasn't changed. No new data.") - return False + return [] # return empty list if nothing has changed with open(self.log_path, "r") as fp: fp.seek(self._last_position) for i, line in enumerate(fp): @@ -720,6 +720,7 @@ class LogService(SimpleService): return False def create(self): + # set cursor at last byte of log file self._last_position = os.path.getsize(self.log_path) status = SimpleService.create(self) # self._last_position = 0