Logging, more documentation
This commit is contained in:
parent
6eebab871e
commit
4a5f630d40
11 changed files with 66 additions and 27 deletions
|
@ -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)
|
||||
|
|
Reference in a new issue