fix issue with rotating log
paulfantom committed
Jul 1, 2016 at 14:06 UTC
bd394e75ed9f05e74f349445f67c790e2f8268bf
1 file changed
+4
python.d/python_modules/base.py
+4
@@ -437,16 +437,20 @@ class LogService(SimpleService):
437
# self._log_reader = Popen(['tail', '-F', self.log_path], stdout=PIPE, stderr=STDOUT)
438
lines = []
439
last = 0
440
+ total = 0
441
try:
442
with open(self.log_path) as fp:
443
for i, line in enumerate(fp):
444
if i > self._last_line:
445
lines.append(line)
446
last = i
447
+ total += 1
448
except Exception as e:
449
msg.error(self.__module__, str(e))
450
if last != 0:
451
self._last_line = last
452
+ elif self._last_line > total:
453
+ self._last_line = 0
454
455
if len(lines) != 0:
456
return lines