kopia lustrzana https://github.com/Yakifo/amqtt
Join logging plugins modules
rodzic
872ca87d4d
commit
2ff81f29bd
|
@ -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
|
|
@ -0,0 +1 @@
|
|||
__author__ = 'nico'
|
|
@ -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)
|
|
@ -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
|
6
setup.py
6
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',
|
||||
]
|
||||
}
|
||||
)
|
Ładowanie…
Reference in New Issue