platypush/platypush/logger.py
Fabio Manganiello 37dcaba7a1
Refactored structure of main application and startup scripts.
The main application class has been moved from __init__ to the app
module.

__init__ will contain instead the relevant global variables and the
modules and objects exposed to external integrations - such as
`get_plugin` and `get_backend`, or the `main` itself.

This will make future integrations much easier - the global __init__
doesn't contain any business logic now, it can import anything without
fearing circular dependencies, and it can limit its exposed objects to
those that we want to expose to 3rd-party integrations and scripts.

It will also make it easier to extend the main entry point with
additional logic - such as a supervisor or an embedded Redis server.
2023-07-23 23:12:36 +02:00

26 lines
574 B
Python

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
def getvalue(self):
"""
This function only serves to prevent PyCharm unit tests from failing when the stdout is redirected to the
Logger.
"""
# vim:sw=4:ts=4:et: