Skip to content

Commit bc4efc2

Browse files
committed
lightningd: pass all log lines to warning notifiers.
It would be wrong to omit those prior to the last, and I want to see what test this was supposedly breaking... Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent 37d0e51 commit bc4efc2

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

lightningd/plugin.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -525,12 +525,8 @@ static const char *plugin_log_handle(struct plugin *plugin,
525525
lines = tal_strsplit(tmpctx, log_msg, "\n", STR_EMPTY_OK);
526526

527527
for (size_t i = 0; lines[i]; i++) {
528-
bool call_notifier2 = call_notifier;
529-
/* Call notifier only for the last message to avoid Python errors. */
530-
if (lines[i+1] != NULL)
531-
call_notifier2 = false;
532528
/* FIXME: Let plugin specify node_id? */
533-
log_(plugin->log, level, NULL, call_notifier2, "%s", lines[i]);
529+
log_(plugin->log, level, NULL, call_notifier, "%s", lines[i]);
534530
}
535531
} else {
536532
log_(plugin->log, level, NULL, call_notifier, "%.*s",

tests/test_plugin.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,7 @@ def test_htlc_accepted_hook_forward_restart(node_factory, executor):
12561256
def test_warning_notification(node_factory):
12571257
""" test 'warning' notifications
12581258
"""
1259-
l1 = node_factory.get_node(options={'plugin': os.path.join(os.getcwd(), 'tests/plugins/pretend_badlog.py')}, broken_log=r'Test warning notification\(for broken event\)')
1259+
l1 = node_factory.get_node(options={'plugin': os.path.join(os.getcwd(), 'tests/plugins/pretend_badlog.py')}, broken_log=r'Test warning notification\(for broken event\)|LINE[12]')
12601260

12611261
# 1. test 'warn' level
12621262
event = "Test warning notification(for unusual event)"
@@ -1283,6 +1283,15 @@ def test_warning_notification(node_factory):
12831283
l1.daemon.wait_for_log('plugin-pretend_badlog.py: source: plugin-pretend_badlog.py')
12841284
l1.daemon.wait_for_log('plugin-pretend_badlog.py: log: Test warning notification\\(for broken event\\)')
12851285

1286+
# Test linesplitting while we're here
1287+
l1.rpc.call('pretendbad', {'event': 'LINE1\nLINE2', 'level': 'error'})
1288+
l1.daemon.wait_for_log(r'\*\*BROKEN\*\* plugin-pretend_badlog.py: LINE1')
1289+
l1.daemon.wait_for_log(r'\*\*BROKEN\*\* plugin-pretend_badlog.py: LINE2')
1290+
l1.daemon.wait_for_log('plugin-pretend_badlog.py: Received warning')
1291+
l1.daemon.wait_for_log('plugin-pretend_badlog.py: log: LINE1')
1292+
l1.daemon.wait_for_log('plugin-pretend_badlog.py: Received warning')
1293+
l1.daemon.wait_for_log('plugin-pretend_badlog.py: log: LINE2')
1294+
12861295

12871296
def test_invoice_payment_notification(node_factory):
12881297
"""

0 commit comments

Comments
 (0)