mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-03 22:37:49 +00:00
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>
This commit is contained in:
parent
834585bdb9
commit
3bcdae106e
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -68,6 +68,7 @@ struct zlog_live_cfg {
|
||||
|
||||
extern void zlog_live_open(struct zlog_live_cfg *cfg, int prio_min,
|
||||
int *other_fd);
|
||||
extern void zlog_live_open_fd(struct zlog_live_cfg *cfg, int prio_min, int fd);
|
||||
|
||||
static inline bool zlog_live_is_null(struct zlog_live_cfg *cfg)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user