Skip to content

Commit

Permalink
docs: adds documentation about the log notification
Browse files Browse the repository at this point in the history
Changelog-None: docs: adds documentation about the log notification
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
  • Loading branch information
vincenzopalazzo committed Jan 12, 2024
1 parent add6e60 commit e46eb96
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ A notification for topic `warning` is sent every time a new `BROKEN`/`UNUSUAL` l
`jcon fd <error_fd_to_jsonrpc>:`, `plugin-manager`;
4. `log` is the context of the original log entry.

There is also a more general version of this notification called `log`, which has the same payload. This needs to be used with caution, but it is useful for plugins that report logs remotely. For example: using OpenTelemetry.

### `forward_event`

A notification for topic `forward_event` is sent every time the status of a forward payment is set. The json format is same as the API `listforwards`.
Expand Down
2 changes: 1 addition & 1 deletion lightningd/notification.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static void log_notification_serialize(struct json_stream *stream,
if (l->level >= LOG_UNUSUAL)
json_object_start(stream, "warning");
else
json_object_start(stream, NULL);
json_object_start(stream, "log");
if (l->level >= LOG_UNUSUAL)
/* Choose "BROKEN"/"UNUSUAL" to keep consistent with the habit
* of plugin. But this may confuses the users who want to 'getlog'
Expand Down
8 changes: 6 additions & 2 deletions lightningd/plugin.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "ccan/str/str.h"
#include "config.h"
#include <ccan/array_size/array_size.h>
#include <ccan/ccan/tal/grab_file/grab_file.h>
Expand Down Expand Up @@ -2324,8 +2325,11 @@ static bool plugin_subscriptions_contains(struct plugin *plugin,
{
for (size_t i = 0; i < tal_count(plugin->subscriptions); i++) {
if (streq(method, plugin->subscriptions[i])
/* Asterisk is magic "all" */
|| streq(plugin->subscriptions[i], "*")) {
/* Asterisk is magic "all", and log notification
* is a special notification that must be turn on
* only if requested. */
|| (streq(plugin->subscriptions[i], "*")
&& !streq(plugin->subscriptions[i], "log"))) {
return true;
}
}
Expand Down
6 changes: 5 additions & 1 deletion plugins/libplugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,11 @@ static void ld_command_handle(struct plugin *plugin,
for (size_t i = 0; i < plugin->num_notif_subs; i++) {
if (streq(cmd->methodname,
plugin->notif_subs[i].name)
|| streq(plugin->notif_subs[i].name, "*")) {
/* * is a special case that means all, but log is another special
* case that can impact performance so this notification is turned
* only when directly specified by a plugin. */
|| (streq(plugin->notif_subs[i].name, "*")
&& !streq(plugin->notif_subs[i].name, "log"))) {
plugin->notif_subs[i].handle(cmd,
plugin->buffer,
paramstok);
Expand Down

0 comments on commit e46eb96

Please sign in to comment.