diff options
author | David Lamparter <equinox@opensourcerouting.org> | 2022-03-05 19:43:44 +0100 |
---|---|---|
committer | David Lamparter <equinox@opensourcerouting.org> | 2022-03-07 18:03:16 +0100 |
commit | 3bcdae106e76f3f7259a1e9c251993ec7e33dc96 (patch) | |
tree | 2841114ad6e6267a2de55499bd81743f340a55d4 /lib/zlog_live.c | |
parent | lib: add a few more bits to live log header (diff) | |
download | frr-3bcdae106e76f3f7259a1e9c251993ec7e33dc96.tar.xz frr-3bcdae106e76f3f7259a1e9c251993ec7e33dc96.zip |
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/zlog_live.c')
-rw-r--r-- | lib/zlog_live.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/zlog_live.c b/lib/zlog_live.c index fd2291a86..d871e20db 100644 --- a/lib/zlog_live.c +++ b/lib/zlog_live.c @@ -182,8 +182,6 @@ static void zlog_live_sigsafe(struct zlog_target *zt, const char *text, void zlog_live_open(struct zlog_live_cfg *cfg, int prio_min, int *other_fd) { int sockets[2]; - struct zlt_live *zte; - struct zlog_target *zt; if (cfg->target) zlog_live_close(cfg); @@ -208,13 +206,23 @@ void zlog_live_open(struct zlog_live_cfg *cfg, int prio_min, int *other_fd) shutdown(sockets[0], SHUT_RD); *other_fd = sockets[1]; + zlog_live_open_fd(cfg, prio_min, sockets[0]); +} + +void zlog_live_open_fd(struct zlog_live_cfg *cfg, int prio_min, int fd) +{ + struct zlt_live *zte; + struct zlog_target *zt; + + if (cfg->target) + zlog_live_close(cfg); zt = zlog_target_clone(MTYPE_LOG_LIVE, NULL, sizeof(*zte)); zte = container_of(zt, struct zlt_live, zt); cfg->target = zte; - set_nonblocking(sockets[0]); - zte->fd = sockets[0]; + set_nonblocking(fd); + zte->fd = fd; zte->zt.prio_min = prio_min; zte->zt.logfn = zlog_live; zte->zt.logfn_sigsafe = zlog_live_sigsafe; |