diff --git a/plugin_test/boswatch.log b/plugin_test/boswatch.log new file mode 100644 index 0000000..dc860c0 --- /dev/null +++ b/plugin_test/boswatch.log @@ -0,0 +1,43 @@ +18.05.2015 12:00:39 - INFO: Alarm! +18.05.2015 12:00:39 - DEBUG: Loading plugin template +18.05.2015 12:00:39 - DEBUG: Throw Template Plugin +18.05.2015 12:00:40 - INFO: Alarm! +18.05.2015 12:00:40 - DEBUG: Loading plugin template +18.05.2015 12:00:40 - DEBUG: Throw Template Plugin +18.05.2015 12:00:41 - INFO: Alarm! +18.05.2015 12:00:41 - DEBUG: Loading plugin template +18.05.2015 12:00:41 - DEBUG: Throw Template Plugin +18.05.2015 12:00:42 - INFO: Alarm! +18.05.2015 12:00:42 - DEBUG: Loading plugin template +18.05.2015 12:00:42 - DEBUG: Throw Template Plugin +18.05.2015 12:01:58 - INFO: Alarm! +18.05.2015 12:01:58 - DEBUG: Loading plugin template +18.05.2015 12:01:58 - DEBUG: Throw Template Plugin +18.05.2015 12:01:58 - DEBUG: try 5/0 +18.05.2015 12:02:09 - INFO: Alarm! +18.05.2015 12:02:09 - DEBUG: Loading plugin template +18.05.2015 12:02:09 - DEBUG: Throw Template Plugin +18.05.2015 12:02:09 - DEBUG: try 5/0 +18.05.2015 12:02:09 - ERROR: Error in Template Plugin +Traceback (most recent call last): + File "./plugins\template\__init__.py", line 7, in run + test = 5/0 +ZeroDivisionError: division by zero +18.05.2015 12:02:10 - INFO: Alarm! +18.05.2015 12:02:10 - DEBUG: Loading plugin template +18.05.2015 12:02:10 - DEBUG: Throw Template Plugin +18.05.2015 12:02:10 - DEBUG: try 5/0 +18.05.2015 12:02:10 - ERROR: Error in Template Plugin +Traceback (most recent call last): + File "./plugins\template\__init__.py", line 7, in run + test = 5/0 +ZeroDivisionError: division by zero +18.05.2015 12:02:11 - INFO: Alarm! +18.05.2015 12:02:11 - DEBUG: Loading plugin template +18.05.2015 12:02:11 - DEBUG: Throw Template Plugin +18.05.2015 12:02:11 - DEBUG: try 5/0 +18.05.2015 12:02:11 - ERROR: Error in Template Plugin +Traceback (most recent call last): + File "./plugins\template\__init__.py", line 7, in run + test = 5/0 +ZeroDivisionError: division by zero diff --git a/plugin_test/plugin_test.py b/plugin_test/plugin_test.py index daff263..314b890 100644 --- a/plugin_test/plugin_test.py +++ b/plugin_test/plugin_test.py @@ -4,10 +4,23 @@ import time import pluginloader +import logging +logging.basicConfig(filename='boswatch.log',level=logging.DEBUG, format='%(asctime)s - %(levelname)s: %(message)s', datefmt='%d.%m.%Y %I:%M:%S') + +#https://docs.python.org/2/howto/logging.html#logging-basic-tutorial +#log levels +#debug - debug messages only for log +#info - only an information +#warning +#error - normal error - program goes further +#exception - error handler in try:exc: into the message +#critical - big error, program exit + while True: time.sleep(1) print ("Alarm!") + logging.info("Alarm!") for i in pluginloader.getPlugins(): - print("Loading plugin " + i["name"]) + logging.debug("Loading plugin " + i["name"]) plugin = pluginloader.loadPlugin(i) - plugin.run() \ No newline at end of file + plugin.run("zvei","","","12345","","") \ No newline at end of file diff --git a/plugin_test/plugins/http/__init__.py b/plugin_test/plugins/http/__init__.py deleted file mode 100644 index 5f1887e..0000000 --- a/plugin_test/plugins/http/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -def run(): - print("throw HTTP Plugin") \ No newline at end of file diff --git a/plugin_test/plugins/interface.txt b/plugin_test/plugins/interface.txt new file mode 100644 index 0000000..6f70513 --- /dev/null +++ b/plugin_test/plugins/interface.txt @@ -0,0 +1,26 @@ +ZVEI: +===== +typ = zvei +time = datetime +frequenz= empfangsfrequenz +data1 = zvei code +data2 = +data3 = + +FMS: +==== +typ = fms +time = datetime +frequenz= empfangsfrequenz +data1 = fms kennung +data2 = status +data3 = richtung + +POCSAG 1200: +============ +typ = poc1200 +time = datetime +frequenz= empfangsfrequenz +data1 = ric +data2 = sub_ric +data3 = text \ No newline at end of file diff --git a/plugin_test/plugins/mysql/__init__.py b/plugin_test/plugins/mysql/__init__.py deleted file mode 100644 index c61db52..0000000 --- a/plugin_test/plugins/mysql/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -def run(): - print("Throw MySql Plugin") \ No newline at end of file diff --git a/plugin_test/plugins/template/__init__.py b/plugin_test/plugins/template/__init__.py index 1f27ab2..99de197 100644 --- a/plugin_test/plugins/template/__init__.py +++ b/plugin_test/plugins/template/__init__.py @@ -1,2 +1,9 @@ -def run(): - print("Throw template Plugin") \ No newline at end of file +import logging + +def run(typ,time,frequenz,data1,data2,data3): + logging.debug("Throw Template Plugin") + try: + logging.debug("try 5/0") + test = 5/0 + except: + logging.exception("Error in Template Plugin") \ No newline at end of file