From cc34fb7b922f183e6ece5fa0fec31d4eb95c5823 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Thu, 19 Jan 2023 13:06:19 +0100 Subject: logd: add support for subscribing to the log object Provides easier access to log messages Signed-off-by: Felix Fietkau --- log/logd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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); -- cgit v1.2.1