summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@nbd.name>2023-01-19 13:06:19 +0100
committerFelix Fietkau <nbd@nbd.name>2023-01-19 13:06:21 +0100
commitcc34fb7b922f183e6ece5fa0fec31d4eb95c5823 (patch)
tree84dfeebce2ee9239552361125b593a4a1f431f88
parent4c7b720b9c63b826fb9404e454ae54f2ef5649d5 (diff)
downloadubox-master.tar.gz
logd: add support for subscribing to the log objectHEADmaster
Provides easier access to log messages Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rw-r--r--log/logd.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/log/logd.c b/log/logd.c
index 594b1e0..94c7b2f 100644
--- a/log/logd.c
+++ b/log/logd.c
@@ -207,7 +207,7 @@ ubus_notify_log(struct log_head *l)
{
struct client *c;
- if (list_empty(&clients))
+ if (list_empty(&clients) && !log_object.has_subscribers)
return;
blob_buf_init(&b, 0);
@@ -217,6 +217,9 @@ ubus_notify_log(struct log_head *l)
blobmsg_add_u32(&b, "source", l->source);
blobmsg_add_u64(&b, "time", (((__u64) l->ts.tv_sec) * 1000) + (l->ts.tv_nsec / 1000000));
+ if (log_object.has_subscribers)
+ ubus_notify(&conn.ctx, &log_object, "message", b.head, -1);
+
list_for_each_entry(c, &clients, list)
ustream_write(&c->s.stream, (void *) b.head, blob_len(b.head) + sizeof(struct blob_attr), false);