first commit

This commit is contained in:
2019-12-14 11:47:50 +08:00
commit 9924a30108
12 changed files with 336 additions and 0 deletions

19
plugins/logger.py Normal file
View File

@@ -0,0 +1,19 @@
import threading
from mswp import Datapack
from forwarder import receive_queues
receive_queue = receive_queues[__name__]
def main():
while True:
dp = receive_queue.get()
print('Writedown log: %s' % dp.body.decode())
with open('logger.log', 'a') as f:
if dp.head.get('from'):
from_app_name = dp.head.get('from')
else:
from_app_name = 'Unknown'
f.write(from_app_name + ': ' + dp.body.decode() + '\n')
thread = threading.Thread(target=main, args=())
thread.start()