Join logging plugins modules

pull/8/head
Nicolas Jouanin 2015-08-21 20:44:20 +02:00
rodzic 872ca87d4d
commit 2ff81f29bd
5 zmienionych plików z 19 dodań i 27 usunięć

Wyświetl plik

@ -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

Wyświetl plik

@ -0,0 +1 @@
__author__ = 'nico'

Wyświetl plik

@ -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)

Wyświetl plik

@ -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

Wyświetl plik

@ -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',
]
}
)