diff --git a/hbmqtt/plugins/__init__.py b/hbmqtt/plugins/__init__.py index eadc386..c8cf453 100644 --- a/hbmqtt/plugins/__init__.py +++ b/hbmqtt/plugins/__init__.py @@ -2,6 +2,3 @@ # # See the file license.txt for copying permission. -from .event_logger import EventLoggerPlugin -# TODO: File is missing -from .packet_logger import PacketLoggerPlugin \ No newline at end of file diff --git a/hbmqtt/plugins/authentication.py b/hbmqtt/plugins/authentication.py new file mode 100644 index 0000000..e1bd617 --- /dev/null +++ b/hbmqtt/plugins/authentication.py @@ -0,0 +1 @@ +__author__ = 'nico' diff --git a/hbmqtt/plugins/event_logger.py b/hbmqtt/plugins/event_logger.py deleted file mode 100644 index 2046425..0000000 --- a/hbmqtt/plugins/event_logger.py +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright (c) 2015 Nicolas JOUANIN -# -# See the file license.txt for copying permission. - -import logging -import asyncio -from functools import partial - - -class EventLoggerPlugin: - def __init__(self, context): - self.logger = logging.getLogger(__name__) - self.context = context - - @asyncio.coroutine - def log_event(self, *args, **kwargs): - self.logger.info("### '%s' EVENT FIRED ###" % kwargs['event_name'].replace('old', '')) - - def __getattr__(self, name): - if name.startswith("on_"): - return partial(self.log_event, event_name=name) diff --git a/hbmqtt/plugins/packet_logger.py b/hbmqtt/plugins/logging.py similarity index 68% rename from hbmqtt/plugins/packet_logger.py rename to hbmqtt/plugins/logging.py index 081e727..5dcc017 100644 --- a/hbmqtt/plugins/packet_logger.py +++ b/hbmqtt/plugins/logging.py @@ -2,11 +2,26 @@ # # See the file license.txt for copying permission. + import logging import asyncio from functools import partial +class EventLoggerPlugin: + def __init__(self, context): + self.logger = logging.getLogger(__name__) + self.context = context + + @asyncio.coroutine + def log_event(self, *args, **kwargs): + self.logger.info("### '%s' EVENT FIRED ###" % kwargs['event_name'].replace('old', '')) + + def __getattr__(self, name): + if name.startswith("on_"): + return partial(self.log_event, event_name=name) + + class PacketLoggerPlugin: def __init__(self, context): self.context = context diff --git a/setup.py b/setup.py index 4fd5034..4ddb714 100644 --- a/setup.py +++ b/setup.py @@ -37,11 +37,11 @@ setup( 'event_plugin = tests.plugins.test_manager:EventTestPlugin', ], 'hbmqtt.broker.plugins': [ -# 'event_logger_plugin = hbmqtt.plugins:EventLoggerPlugin', - 'packet_logger_plugin = hbmqtt.plugins:PacketLoggerPlugin', +# 'event_logger_plugin = hbmqtt.plugins.logging:EventLoggerPlugin', + 'packet_logger_plugin = hbmqtt.plugins.logging:PacketLoggerPlugin', ], 'hbmqtt.client.plugins': [ - 'packet_logger_plugin = hbmqtt.plugins:PacketLoggerPlugin', + 'packet_logger_plugin = hbmqtt.plugins.logging:PacketLoggerPlugin', ] } ) \ No newline at end of file