Skip to content

Commit

Permalink
lightningd: pass all log lines to warning notifiers.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
rustyrussell committed Jan 28, 2025
1 parent 5a14c6b commit 937f03d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 1 addition & 5 deletions lightningd/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,12 +516,8 @@ static const char *plugin_log_handle(struct plugin *plugin,
lines = tal_strsplit(tmpctx, log_msg, "\n", STR_EMPTY_OK);

for (size_t i = 0; lines[i]; i++) {
bool call_notifier2 = call_notifier;
/* Call notifier only for the last message to avoid Python errors. */
if (lines[i+1] != NULL)
call_notifier2 = false;
/* FIXME: Let plugin specify node_id? */
log_(plugin->log, level, NULL, call_notifier2, "%s", lines[i]);
log_(plugin->log, level, NULL, call_notifier, "%s", lines[i]);
}
} else {
log_(plugin->log, level, NULL, call_notifier, "%.*s",
Expand Down
11 changes: 10 additions & 1 deletion tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,7 @@ def test_htlc_accepted_hook_forward_restart(node_factory, executor):
def test_warning_notification(node_factory):
""" test 'warning' notifications
"""
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\)')
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]')

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

# Test linesplitting while we're here
l1.rpc.call('pretendbad', {'event': 'LINE1\nLINE2', 'level': 'error'})
l1.daemon.wait_for_log(r'\*\*BROKEN\*\* plugin-pretend_badlog.py: LINE1')
l1.daemon.wait_for_log(r'\*\*BROKEN\*\* plugin-pretend_badlog.py: LINE2')
l1.daemon.wait_for_log('plugin-pretend_badlog.py: Received warning')
l1.daemon.wait_for_log('plugin-pretend_badlog.py: log: LINE1')
l1.daemon.wait_for_log('plugin-pretend_badlog.py: Received warning')
l1.daemon.wait_for_log('plugin-pretend_badlog.py: log: LINE2')


def test_invoice_payment_notification(node_factory):
"""
Expand Down

0 comments on commit 937f03d

Please sign in to comment.