From 8e4cfa29f9295d714bdc0d91e943db38804678e9 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sat, 25 Jun 2016 19:29:00 +0200 Subject: cons: relay log-messages (fixes #144) --- modules/cons/cons.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'modules/cons') diff --git a/modules/cons/cons.c b/modules/cons/cons.c index 89ce028..f652a75 100644 --- a/modules/cons/cons.c +++ b/modules/cons/cons.c @@ -212,6 +212,17 @@ static int output_handler(const char *str) } +/* + * Relay log-messages to all active UDP/TCP connections + */ +static void log_handler(uint32_t level, const char *msg) +{ + (void)level; + + output_handler(msg); +} + + static struct ui ui_cons = { LE_INIT, "cons", @@ -219,6 +230,11 @@ static struct ui ui_cons = { }; +static struct log lg = { + .h = log_handler, +}; + + static int cons_init(void) { struct sa laddr; @@ -234,12 +250,16 @@ static int cons_init(void) ui_register(&ui_cons); + log_register_handler(&lg); + return 0; } static int cons_close(void) { + log_unregister_handler(&lg); + ui_unregister(&ui_cons); cons = mem_deref(cons); return 0; -- cgit v1.2.3