summaryrefslogtreecommitdiff
path: root/lib/log_vty.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2022-03-05 19:43:44 +0100
committerDavid Lamparter <equinox@opensourcerouting.org>2022-03-07 18:03:16 +0100
commit3bcdae106e76f3f7259a1e9c251993ec7e33dc96 (patch)
tree2841114ad6e6267a2de55499bd81743f340a55d4 /lib/log_vty.c
parent834585bdb98a162228399b9eec03b9a17e8d391e (diff)
lib: add `monitor:<fd>` command line log target
This provides direct raw log output with full metadata directly at startup regardless of configuration details. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/log_vty.c')
-rw-r--r--lib/log_vty.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/log_vty.c b/lib/log_vty.c
index 682c9ea372..ef33a39d4a 100644
--- a/lib/log_vty.c
+++ b/lib/log_vty.c
@@ -427,6 +427,22 @@ void command_setup_early_logging(const char *dest, const char *level)
set_log_file(&zt_file_cmdline, NULL, sep, nlevel);
return;
}
+ if (strcmp(type, "monitor") == 0 && sep) {
+ struct zlog_live_cfg cfg = {};
+ unsigned long fd;
+ char *endp;
+
+ sep++;
+ fd = strtoul(sep, &endp, 10);
+ if (!*sep || *endp) {
+ fprintf(stderr, "invalid monitor fd \"%s\"\n", sep);
+ exit(1);
+ }
+
+ zlog_live_open_fd(&cfg, nlevel, fd);
+ zlog_live_disown(&cfg);
+ return;
+ }
fprintf(stderr, "invalid log target \"%s\" (\"%s\")\n", type, dest);
exit(1);