fixed error in logger causing rpi to think logging server is down

This commit is contained in:
Joel 2021-01-26 21:18:32 +01:00
parent 4d699181c3
commit e02b42060b
No known key found for this signature in database
GPG key ID: BDDDBECD0808290E
3 changed files with 9 additions and 6 deletions

View file

@ -32,7 +32,7 @@ fpm -s python --python-bin python3 --python-pip pip3 --python-package-name-prefi
-d "python-pigpio" \ -d "python-pigpio" \
-d "python3-pigpio" \ -d "python3-pigpio" \
-d "python3-numpy" \ -d "python3-numpy" \
-v 0.0.3-6 -t deb setup.py -v 0.0.3-7 -t deb setup.py
# --deb-changelog changelog \ # --deb-changelog changelog \
# --deb-upstream-changelog changelog \ # --deb-upstream-changelog changelog \

View file

@ -31,6 +31,7 @@ class StreamToLogger(object):
""" """
Fake file-like stream object that redirects writes to a logger instance. Fake file-like stream object that redirects writes to a logger instance.
""" """
def __init__(self, textio, log_level=logging.INFO): def __init__(self, textio, log_level=logging.INFO):
self.logger = logging.getLogger('logstash') self.logger = logging.getLogger('logstash')
self.console = textio self.console = textio
@ -52,8 +53,8 @@ class StreamToLogger(object):
try: try:
r = requests.head(f"http://{host}:{port}") r = requests.get(f"https://{host}:{port}")
if r.status_code == 400: if r.status_code == 401:
logstash_logger.addHandler(asynchronousLogstashHandler) logstash_logger.addHandler(asynchronousLogstashHandler)
so = StreamToLogger(sys.stdout, logging.INFO) so = StreamToLogger(sys.stdout, logging.INFO)
@ -62,10 +63,11 @@ try:
se = StreamToLogger(sys.stderr, logging.ERROR) se = StreamToLogger(sys.stderr, logging.ERROR)
sys.stderr = se sys.stderr = se
else: else:
print(f"Could not connect to {host} -> {r.status_code}!") print(f"Could not connect to {host} -> ERROR CODE: {r.status_code}!")
except requests.exceptions.ConnectionError as identifier: except requests.exceptions.ConnectionError as identifier:
print(f"Could not connect to {host}!") print(f"Could not connect to {host}!")
print(f"Error loading logger was -> {identifier}")
pass pass
@ -81,7 +83,7 @@ class Logging(object):
:rtype: logging.Logger :rtype: logging.Logger
""" """
return logstash_logger return logstash_logger
@staticmethod @staticmethod
def set_debug(): def set_debug():
"""Turns up the logging level of the library to debug. Should be used, when debugging with the """Turns up the logging level of the library to debug. Should be used, when debugging with the

View file

@ -67,7 +67,8 @@ class __Streaming:
:return: None :return: None
""" """
with self.__lock: with self.__lock:
self.__newest_frame = image.copy() if image is not None:
self.__newest_frame = image.copy()
def _newest_frame_generator(self): def _newest_frame_generator(self):
""" """