Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: add log immediate-mode to running config output #15221

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/log_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,8 @@ void log_config_write(struct vty *vty)
vty_out(vty, "no log error-category\n");
if (!zlog_get_prefix_xid())
vty_out(vty, "no log unique-id\n");
if (zlog_get_immediate_mode())
vty_out(vty, "log immediate-mode\n");

if (logmsgs_with_persist_bt) {
struct xrefdata *xrd;
Expand Down
11 changes: 8 additions & 3 deletions lib/zlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static struct zlog_targets_head zlog_targets;
/* Global setting for buffered vs immediate output. The default is
* per-pthread buffering.
*/
static bool default_immediate;
static bool zlog_default_immediate;

/* cf. zlog.h for additional comments on this struct.
*
Expand Down Expand Up @@ -445,7 +445,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 = default_immediate;
bool immediate = zlog_default_immediate;

/* avoid further processing cost if no target wants this message */
rcu_read_lock();
Expand Down Expand Up @@ -966,7 +966,12 @@ struct zlog_target *zlog_target_replace(struct zlog_target *oldzt,
*/
void zlog_set_immediate(bool set_p)
{
default_immediate = set_p;
zlog_default_immediate = set_p;
}

bool zlog_get_immediate_mode(void)
{
return zlog_default_immediate;
}

/* common init */
Expand Down
1 change: 1 addition & 0 deletions lib/zlog.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ 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);
bool zlog_get_immediate_mode(void);

extern const char *zlog_priority_str(int priority);

Expand Down
Loading