summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAlfred E. Heggestad <aeh@db.org>2016-06-25 19:29:00 +0200
committerAlfred E. Heggestad <aeh@db.org>2016-06-25 19:29:00 +0200
commit8e4cfa29f9295d714bdc0d91e943db38804678e9 (patch)
tree80139f9af1c83ce053b5742a352796365ca927ea /modules
parent0f952c19f6b9b7c0ecb4e76f234ff3233e3d99c5 (diff)
cons: relay log-messages (fixes #144)
Diffstat (limited to 'modules')
-rw-r--r--modules/cons/cons.c20
1 files changed, 20 insertions, 0 deletions
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;