mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2026-01-20 23:30:17 +01:00
simple logging and data output with plugin
This commit is contained in:
parent
466e017cfb
commit
947bc9417c
43
plugin_test/boswatch.log
Normal file
43
plugin_test/boswatch.log
Normal file
|
|
@ -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
|
||||
|
|
@ -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()
|
||||
plugin.run("zvei","","","12345","","")
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
def run():
|
||||
print("throw HTTP Plugin")
|
||||
26
plugin_test/plugins/interface.txt
Normal file
26
plugin_test/plugins/interface.txt
Normal file
|
|
@ -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
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
def run():
|
||||
print("Throw MySql Plugin")
|
||||
|
|
@ -1,2 +1,9 @@
|
|||
def run():
|
||||
print("Throw template Plugin")
|
||||
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")
|
||||
Loading…
Reference in a new issue