diff --git a/platypush/__init__.py b/platypush/__init__.py index 82a234303..e5ed492da 100644 --- a/platypush/__init__.py +++ b/platypush/__init__.py @@ -19,6 +19,7 @@ from .config import Config from .context import register_backends from .cron.scheduler import CronScheduler from .event.processor import EventProcessor +from .logger import Logger from .message.event import Event, StopEvent from .message.event.application import ApplicationStartedEvent, ApplicationStoppedEvent from .message.request import Request @@ -29,6 +30,7 @@ __author__ = 'Fabio Manganiello ' __version__ = '0.9.3' LOGGER = logging.getLogger(__name__) +LOGGER.setLevel(logging.INFO) class Daemon: """ Main class for the Platypush daemon """ @@ -171,6 +173,8 @@ def main(): Platypush daemon main """ + sys.stdout = Logger(LOGGER.info) + sys.stderr = Logger(LOGGER.warning) print('Starting platypush v.{}'.format(__version__)) app = Daemon.build_from_cmdline(sys.argv[1:]) app.start() diff --git a/platypush/logger.py b/platypush/logger.py new file mode 100644 index 000000000..b764a1d05 --- /dev/null +++ b/platypush/logger.py @@ -0,0 +1,17 @@ +import sys + +class Logger: + def __init__(self, level): + self.level = level + + def write(self, message): + if isinstance(message, bytes): + message = message.decode() + if message and message != '\n': + self.level(message.rstrip()) + + def flush(self): + pass + + +# vim:sw=4:ts=4:et: