mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-05 20:51:17 +00:00
libs: add api to enable immediate output of zlog
The log module buffers outgoing messages by default; add an api to turn that off, and emit messages immediately. Signed-off-by: Mark Stapp <mjs@voltanet.io>
This commit is contained in:
parent
7408af70f5
commit
42ddefe816
15
lib/zlog.c
15
lib/zlog.c
@ -81,6 +81,11 @@ static gid_t zlog_gid = -1;
|
||||
DECLARE_ATOMLIST(zlog_targets, struct zlog_target, head);
|
||||
static struct zlog_targets_head zlog_targets;
|
||||
|
||||
/* Global setting for buffered vs immediate output. The default is
|
||||
* per-pthread buffering.
|
||||
*/
|
||||
static bool default_immediate;
|
||||
|
||||
/* cf. zlog.h for additional comments on this struct.
|
||||
*
|
||||
* Note: you MUST NOT pass the format string + va_list to non-FRR format
|
||||
@ -395,7 +400,7 @@ static void vzlog_tls(struct zlog_tls *zlog_tls, const struct xref_logmsg *xref,
|
||||
struct zlog_msg *msg;
|
||||
char *buf;
|
||||
bool ignoremsg = true;
|
||||
bool immediate = false;
|
||||
bool immediate = default_immediate;
|
||||
|
||||
/* avoid further processing cost if no target wants this message */
|
||||
rcu_read_lock();
|
||||
@ -714,6 +719,14 @@ struct zlog_target *zlog_target_replace(struct zlog_target *oldzt,
|
||||
return oldzt;
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable or disable 'immediate' output - default is to buffer
|
||||
* each pthread's messages.
|
||||
*/
|
||||
void zlog_set_immediate(bool set_p)
|
||||
{
|
||||
default_immediate = set_p;
|
||||
}
|
||||
|
||||
/* common init */
|
||||
|
||||
|
@ -249,6 +249,9 @@ extern void zlog_tls_buffer_init(void);
|
||||
extern void zlog_tls_buffer_flush(void);
|
||||
extern void zlog_tls_buffer_fini(void);
|
||||
|
||||
/* Enable or disable 'immediate' output - default is to buffer messages. */
|
||||
extern void zlog_set_immediate(bool set_p);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user