2019-01-27 00:53:30 +01:00
|
|
|
class Logger:
|
|
|
|
def __init__(self, level):
|
|
|
|
self.level = level
|
|
|
|
|
|
|
|
def write(self, message):
|
|
|
|
if message is None:
|
|
|
|
return
|
|
|
|
|
|
|
|
if isinstance(message, bytes):
|
|
|
|
message = message.decode()
|
|
|
|
|
|
|
|
message = message.rstrip()
|
|
|
|
if message and len(message) > 0:
|
|
|
|
self.level(message)
|
|
|
|
|
|
|
|
def flush(self):
|
|
|
|
pass
|
|
|
|
|
2021-02-27 20:27:36 +01:00
|
|
|
def getvalue(self):
|
|
|
|
"""
|
|
|
|
This function only serves to prevent PyCharm unit tests from failing when the stdout is redirected to the
|
|
|
|
Logger.
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
2019-01-27 00:53:30 +01:00
|
|
|
|
|
|
|
# vim:sw=4:ts=4:et:
|