plugin: Handle log notifications from plugins

Logs are parsed and injected into the main daemon's logs.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker
2018-12-06 16:00:08 +01:00
committed by Rusty Russell
parent dc25c43945
commit a304db9be2
3 changed files with 54 additions and 1 deletions

View File

@@ -45,12 +45,27 @@ def json_getmanifest(request):
}
def plugin_log(message, level="info"):
payload = {
"jsonrpc": "2.0",
"method": "log",
"params": {
"level": level,
"message": message,
}
}
json.dump(payload, fp=sys.stdout)
sys.stdout.write('\n\n')
sys.stdout.flush()
def json_init(request, options, configuration):
"""The main daemon is telling us the relevant cli options
"""
global greeting
greeting = request['params']['options']['greeting']
plugin_log("Plugin helloworld.py initialized with greeting \"{}\"".format(greeting), "debug")
return "ok"