From 8c5fe2f5993ac0c78169fecb6b65dc9a9cefc315 Mon Sep 17 00:00:00 2001 From: paulfantom Date: Sat, 23 Jul 2016 21:51:32 +0200 Subject: [PATCH] return empty list if log file hasn't changed. --- python.d/python_modules/base.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 -- 2.39.2