mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
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:
committed by
Rusty Russell
parent
dc25c43945
commit
a304db9be2
@@ -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"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user