kopia lustrzana https://github.com/Yakifo/amqtt
Add EventLoggingModule
rodzic
e44c0b32df
commit
848aaf8438
|
@ -115,7 +115,7 @@ class BrokerContext(BaseContext):
|
||||||
It act as an adapter to broker services from plugins developed for HBMQTT broker
|
It act as an adapter to broker services from plugins developed for HBMQTT broker
|
||||||
"""
|
"""
|
||||||
def __init__(self, loop=None):
|
def __init__(self, loop=None):
|
||||||
super().__init__(self, loop)
|
super().__init__(loop)
|
||||||
|
|
||||||
|
|
||||||
class Broker:
|
class Broker:
|
||||||
|
|
|
@ -1 +1,5 @@
|
||||||
__author__ = 'nico'
|
# Copyright (c) 2015 Nicolas JOUANIN
|
||||||
|
#
|
||||||
|
# See the file license.txt for copying permission.
|
||||||
|
|
||||||
|
from .event_logger import EventLoggerPlugin
|
|
@ -0,0 +1,21 @@
|
||||||
|
# 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, event_name):
|
||||||
|
self.logger.info("### EVENT FIRED: '%s' ###" % event_name)
|
||||||
|
|
||||||
|
def __getattr__(self, name):
|
||||||
|
if name.startswith("on_"):
|
||||||
|
return partial(self.log_event, event_name=name)
|
5
setup.py
5
setup.py
|
@ -34,7 +34,10 @@ setup(
|
||||||
entry_points = {
|
entry_points = {
|
||||||
'hbmqtt.test.plugins': [
|
'hbmqtt.test.plugins': [
|
||||||
'test_plugin = tests.plugins.test_manager:TestPlugin',
|
'test_plugin = tests.plugins.test_manager:TestPlugin',
|
||||||
'event_plugin = tests.plugins.test_manager:EventTestPlugin'
|
'event_plugin = tests.plugins.test_manager:EventTestPlugin',
|
||||||
|
],
|
||||||
|
'hbmqtt.broker': [
|
||||||
|
'event_logger_plugin = hbmqtt.plugins:EventLoggerPlugin',
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
)
|
)
|
Ładowanie…
Reference in New Issue