From 66564c2324abc58b24327b763e1113ff781156a2 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 21 Feb 2019 20:34:01 +0100 Subject: Adding upstream version 1.12.1. Signed-off-by: Daniel Baumann --- .../python_modules/bases/FrameworkServices/LogService.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'collectors/python.d.plugin/python_modules/bases/FrameworkServices') 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) -- cgit v1.2.3