mirror of
https://github.com/samba-team/samba.git
synced 2025-03-11 16:58:40 +03:00
lib/util: add debug_set_forced_log_priority()
By default the priority for syslog/systemd is derived from the log level of the debug message. But for things like startup messages we want to change the priority temporary, like this: debug_set_forced_log_priority(DBGLVL_NOTICE); D_ERR("Startup...\n"); debug_set_forced_log_priority(-1); BUG: https://bugzilla.samba.org/show_bug.cgi?id=15377 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Björn Jacke <bjacke@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
83e8971c0f
commit
bd21a0cdef
@ -94,6 +94,7 @@ static struct {
|
|||||||
char hostname[HOST_NAME_MAX+1];
|
char hostname[HOST_NAME_MAX+1];
|
||||||
bool reopening_logs;
|
bool reopening_logs;
|
||||||
bool schedule_reopen_logs;
|
bool schedule_reopen_logs;
|
||||||
|
int forced_log_priority;
|
||||||
|
|
||||||
struct debug_settings settings;
|
struct debug_settings settings;
|
||||||
debug_callback_fn callback;
|
debug_callback_fn callback;
|
||||||
@ -230,6 +231,10 @@ static int debug_level_to_priority(int level)
|
|||||||
};
|
};
|
||||||
int priority;
|
int priority;
|
||||||
|
|
||||||
|
if (state.forced_log_priority != -1) {
|
||||||
|
level = state.forced_log_priority;
|
||||||
|
}
|
||||||
|
|
||||||
if (level < 0 || (size_t)level >= ARRAY_SIZE(priority_map))
|
if (level < 0 || (size_t)level >= ARRAY_SIZE(priority_map))
|
||||||
priority = LOG_DEBUG;
|
priority = LOG_DEBUG;
|
||||||
else
|
else
|
||||||
@ -1133,6 +1138,11 @@ void debug_set_hostname(const char *name)
|
|||||||
strlcpy(state.hostname, name, sizeof(state.hostname));
|
strlcpy(state.hostname, name, sizeof(state.hostname));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void debug_set_forced_log_priority(int forced_log_priority)
|
||||||
|
{
|
||||||
|
state.forced_log_priority = forced_log_priority;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensure debug logs are initialised.
|
* Ensure debug logs are initialised.
|
||||||
*
|
*
|
||||||
|
@ -356,6 +356,7 @@ void debug_set_settings(struct debug_settings *settings,
|
|||||||
const char *logging_param,
|
const char *logging_param,
|
||||||
int syslog_level, bool syslog_only);
|
int syslog_level, bool syslog_only);
|
||||||
void debug_set_hostname(const char *name);
|
void debug_set_hostname(const char *name);
|
||||||
|
void debug_set_forced_log_priority(int forced_log_priority);
|
||||||
bool reopen_logs_internal( void );
|
bool reopen_logs_internal( void );
|
||||||
void force_check_log_size( void );
|
void force_check_log_size( void );
|
||||||
bool need_to_check_log_size( void );
|
bool need_to_check_log_size( void );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user