Logging, more documentation

This commit is contained in:
Konstantin Lampalzer 2021-01-23 13:37:40 +01:00
parent 6eebab871e
commit 4a5f630d40
No known key found for this signature in database
GPG key ID: 9A60A522835A2AD9
11 changed files with 66 additions and 27 deletions

View file

@ -26,6 +26,7 @@ asynchronousLogstashHandler = AsynchronousLogstashHandler(
database_path='logs.db'
)
class StreamToLogger(object):
"""
Fake file-like stream object that redirects writes to a logger instance.
@ -53,6 +54,7 @@ class StreamToLogger(object):
self.linebuf = ''
asynchronousLogstashHandler.flush()
try:
r = requests.head(f"http://{host}:{port}")
if r.status_code == 400:
@ -67,12 +69,23 @@ except requests.exceptions.ConnectionError as identifier:
print(f"Could not connect to {host}!")
pass
class Logging(object):
"""Can be used to manually use the logger or turn up the logging level used for debugging this library.
"""
@staticmethod
def get_logger() -> logging.Logger:
"""Get the logger object used to communicate with logstash
:return: Python logger
:rtype: logging.Logger
"""
return logstash_logger
@staticmethod
def set_debug():
"""Turns up the logging level of the library to debug. Should be used, when debugging with the
Competition organizers
"""
logstash_logger.setLevel(logging.DEBUG)