summaryrefslogtreecommitdiffstats
path: root/collectors/python.d.plugin/python_modules/bases/FrameworkServices/LogService.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2019-02-21 19:34:01 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2019-02-21 19:34:01 +0000
commit66564c2324abc58b24327b763e1113ff781156a2 (patch)
tree2480212cd47149a3fda5225b57689d0126546e23 /collectors/python.d.plugin/python_modules/bases/FrameworkServices/LogService.py
parentAdding upstream version 1.12.0. (diff)
downloadnetdata-66564c2324abc58b24327b763e1113ff781156a2.tar.xz
netdata-66564c2324abc58b24327b763e1113ff781156a2.zip
Adding upstream version 1.12.1.upstream/1.12.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'collectors/python.d.plugin/python_modules/bases/FrameworkServices/LogService.py')
-rw-r--r--collectors/python.d.plugin/python_modules/bases/FrameworkServices/LogService.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/collectors/python.d.plugin/python_modules/bases/FrameworkServices/LogService.py b/collectors/python.d.plugin/python_modules/bases/FrameworkServices/LogService.py
index 5acfd73f8..82c8d7d95 100644
--- a/collectors/python.d.plugin/python_modules/bases/FrameworkServices/LogService.py
+++ b/collectors/python.d.plugin/python_modules/bases/FrameworkServices/LogService.py
@@ -5,6 +5,7 @@
# SPDX-License-Identifier: GPL-3.0-or-later
from glob import glob
+import sys
import os
from bases.FrameworkServices.SimpleService import SimpleService
@@ -17,6 +18,7 @@ class LogService(SimpleService):
self.__glob_path = self.log_path
self._last_position = 0
self.__re_find = dict(current=0, run=0, maximum=60)
+ self.__open_args = {'errors': 'replace'} if sys.version_info[0] > 2 else {}
def _get_raw_data(self):
"""
@@ -34,7 +36,7 @@ class LogService(SimpleService):
elif size < self._last_position:
self._last_position = 0 # read from beginning if file has shrunk
- with open(self.log_path) as fp:
+ with open(self.log_path, **self.__open_args) as fp:
fp.seek(self._last_position)
for line in fp:
lines.append(line)