mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 16:04:49 +00:00
lib: support multiple --log
options
Allow simultaneously enabling syslog, stdout and/or file logs. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
parent
2eda953a2a
commit
da2fc19187
17
lib/libfrr.c
17
lib/libfrr.c
@ -333,6 +333,8 @@ void frr_preinit(struct frr_daemon_info *daemon, int argc, char **argv)
|
||||
|
||||
umask(0027);
|
||||
|
||||
log_args_init(daemon->early_logging);
|
||||
|
||||
opt_extend(&os_always);
|
||||
if (!(di->flags & FRR_NO_SPLIT_CONFIG))
|
||||
opt_extend(&os_cfg);
|
||||
@ -431,6 +433,8 @@ static int frr_opt(int opt)
|
||||
static int vty_port_set = 0;
|
||||
static int vty_addr_set = 0;
|
||||
struct option_chain *oc;
|
||||
struct log_arg *log_arg;
|
||||
size_t arg_len;
|
||||
char *err;
|
||||
|
||||
switch (opt) {
|
||||
@ -613,7 +617,10 @@ static int frr_opt(int opt)
|
||||
di->privs->group = optarg;
|
||||
break;
|
||||
case OPTION_LOG:
|
||||
di->early_logging = optarg;
|
||||
arg_len = strlen(optarg) + 1;
|
||||
log_arg = XCALLOC(MTYPE_TMP, sizeof(*log_arg) + arg_len);
|
||||
memcpy(log_arg->target, optarg, arg_len);
|
||||
log_args_add_tail(di->early_logging, log_arg);
|
||||
break;
|
||||
case OPTION_LOGLEVEL:
|
||||
di->early_loglevel = optarg;
|
||||
@ -706,10 +713,12 @@ static struct thread_master *master;
|
||||
struct thread_master *frr_init(void)
|
||||
{
|
||||
struct option_chain *oc;
|
||||
struct log_arg *log_arg;
|
||||
struct frrmod_runtime *module;
|
||||
struct zprivs_ids_t ids;
|
||||
char p_instance[16] = "", p_pathspace[256] = "";
|
||||
const char *dir;
|
||||
|
||||
dir = di->module_path ? di->module_path : frr_moduledir;
|
||||
|
||||
srandom(time(NULL));
|
||||
@ -739,7 +748,11 @@ struct thread_master *frr_init(void)
|
||||
zlog_init(di->progname, di->logname, di->instance,
|
||||
ids.uid_normal, ids.gid_normal);
|
||||
|
||||
command_setup_early_logging(di->early_logging, di->early_loglevel);
|
||||
while ((log_arg = log_args_pop(di->early_logging))) {
|
||||
command_setup_early_logging(log_arg->target,
|
||||
di->early_loglevel);
|
||||
XFREE(MTYPE_TMP, log_arg);
|
||||
}
|
||||
|
||||
if (!frr_zclient_addr(&zclient_addr, &zclient_addr_len,
|
||||
frr_zclientpath)) {
|
||||
|
11
lib/libfrr.h
11
lib/libfrr.h
@ -21,6 +21,7 @@
|
||||
#ifndef _ZEBRA_FRR_H
|
||||
#define _ZEBRA_FRR_H
|
||||
|
||||
#include "typesafe.h"
|
||||
#include "sigevent.h"
|
||||
#include "privs.h"
|
||||
#include "thread.h"
|
||||
@ -52,6 +53,14 @@ extern "C" {
|
||||
*/
|
||||
#define FRR_DETACH_LATER (1 << 6)
|
||||
|
||||
PREDECL_DLIST(log_args);
|
||||
struct log_arg {
|
||||
struct log_args_item itm;
|
||||
|
||||
char target[0];
|
||||
};
|
||||
DECLARE_DLIST(log_args, struct log_arg, itm);
|
||||
|
||||
enum frr_cli_mode {
|
||||
FRR_CLI_CLASSIC = 0,
|
||||
FRR_CLI_TRANSACTIONAL,
|
||||
@ -88,7 +97,7 @@ struct frr_daemon_info {
|
||||
const char *pathspace;
|
||||
bool zpathspace;
|
||||
|
||||
const char *early_logging;
|
||||
struct log_args_head early_logging[1];
|
||||
const char *early_loglevel;
|
||||
|
||||
const char *proghelp;
|
||||
|
Loading…
Reference in New Issue
Block a user