summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_main.c3
-rw-r--r--ldpd/ldpd.c4
-rw-r--r--lib/command.c2
-rw-r--r--lib/filter.c2
-rw-r--r--lib/grammar_sandbox_main.c2
-rw-r--r--lib/libfrr.c2
-rw-r--r--lib/libfrr.h4
-rw-r--r--lib/log.c43
-rw-r--r--lib/log.h31
-rw-r--r--lib/plist.c2
-rw-r--r--lib/routemap.c4
-rw-r--r--lib/vty.c4
-rw-r--r--ospf6d/ospf6_main.c3
-rw-r--r--tests/lib/cli/common_cli.c6
-rw-r--r--tests/lib/test_segv.c3
-rw-r--r--tests/lib/test_sig.c5
-rw-r--r--zebra/main.c3
-rw-r--r--zebra/test_main.c3
18 files changed, 38 insertions, 88 deletions
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c
index ba95a56074..b2b7eec3a3 100644
--- a/bgpd/bgp_main.c
+++ b/bgpd/bgp_main.c
@@ -240,8 +240,7 @@ bgp_exit (int status)
if (bm->master)
thread_master_free (bm->master);
- if (zlog_default)
- closezlog (zlog_default);
+ closezlog ();
memset (bm, 0, sizeof (*bm));
diff --git a/ldpd/ldpd.c b/ldpd/ldpd.c
index 205449db3e..dc263875e2 100644
--- a/ldpd/ldpd.c
+++ b/ldpd/ldpd.c
@@ -254,7 +254,7 @@ main(int argc, char *argv[])
exit(1);
}
- zlog_default = openzlog(ldpd_di.progname, ZLOG_LDP, 0,
+ openzlog(ldpd_di.progname, "LDP", 0,
LOG_CONS | LOG_NDELAY | LOG_PID, LOG_DAEMON);
if (lflag)
@@ -407,7 +407,7 @@ ldpd_shutdown(void)
ldp_zebra_destroy();
zprivs_terminate(&ldpd_privs);
thread_master_free(master);
- closezlog(zlog_default);
+ closezlog();
exit(0);
}
diff --git a/lib/command.c b/lib/command.c
index 10d36370d1..843529b36f 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -2214,7 +2214,7 @@ DEFUN (show_logging,
vty_out (vty, "%s", VTY_NEWLINE);
vty_out (vty, "Protocol name: %s%s",
- zlog_proto_names[zl->protocol], VTY_NEWLINE);
+ zl->protoname, VTY_NEWLINE);
vty_out (vty, "Record priority: %s%s",
(zl->record_priority ? "enabled" : "disabled"), VTY_NEWLINE);
vty_out (vty, "Timestamp precision: %d%s",
diff --git a/lib/filter.c b/lib/filter.c
index 2b9ba87137..58138b2978 100644
--- a/lib/filter.c
+++ b/lib/filter.c
@@ -1699,7 +1699,7 @@ filter_show (struct vty *vty, const char *name, afi_t afi)
/* Print the name of the protocol */
if (zlog_default)
vty_out (vty, "%s:%s",
- zlog_proto_names[zlog_default->protocol], VTY_NEWLINE);
+ zlog_default->protoname, VTY_NEWLINE);
for (access = master->num.head; access; access = access->next)
{
diff --git a/lib/grammar_sandbox_main.c b/lib/grammar_sandbox_main.c
index 5deef406c1..fa925c4647 100644
--- a/lib/grammar_sandbox_main.c
+++ b/lib/grammar_sandbox_main.c
@@ -40,7 +40,7 @@ int main(int argc, char **argv)
master = thread_master_create ();
- zlog_default = openzlog ("grammar_sandbox", ZLOG_NONE, 0,
+ openzlog ("grammar_sandbox", "NONE", 0,
LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON);
zlog_set_level (NULL, ZLOG_DEST_SYSLOG, ZLOG_DISABLED);
zlog_set_level (NULL, ZLOG_DEST_STDOUT, LOG_DEBUG);
diff --git a/lib/libfrr.c b/lib/libfrr.c
index 570d9724d7..f9ac3158a3 100644
--- a/lib/libfrr.c
+++ b/lib/libfrr.c
@@ -300,7 +300,7 @@ struct thread_master *frr_init(void)
srandom(time(NULL));
- zlog_default = openzlog (di->progname, di->log_id, di->instance,
+ openzlog (di->progname, di->logname, di->instance,
LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON);
#if defined(HAVE_CUMULUS)
zlog_set_level (NULL, ZLOG_DEST_SYSLOG, zlog_default->default_lvl);
diff --git a/lib/libfrr.h b/lib/libfrr.h
index ae4a5176a3..d37f406f5b 100644
--- a/lib/libfrr.h
+++ b/lib/libfrr.h
@@ -38,7 +38,7 @@ struct frr_daemon_info {
const char *progname;
const char *name;
- zlog_proto_t log_id;
+ const char *logname;
unsigned short instance;
char *vty_addr;
@@ -73,7 +73,7 @@ struct frr_daemon_info {
#define FRR_DAEMON_INFO(execname, constname, ...) \
static struct frr_daemon_info execname ##_di = { \
.name = # execname, \
- .log_id = ZLOG_ ## constname, \
+ .logname = # constname, \
__VA_ARGS__ \
};
diff --git a/lib/log.c b/lib/log.c
index 60eeede7bf..8986a8ada7 100644
--- a/lib/log.c
+++ b/lib/log.c
@@ -42,29 +42,6 @@ static int logfile_fd = -1; /* Used in signal handler. */
struct zlog *zlog_default = NULL;
-/*
- * This must be kept in the same order as the
- * zlog_proto_t enum
- */
-const char *zlog_proto_names[] =
-{
- "NONE",
- "DEFAULT",
- "ZEBRA",
- "RIP",
- "BGP",
- "OSPF",
- "RIPNG",
- "OSPF6",
- "LDP",
- "ISIS",
- "PIM",
- "NHRP",
- "RFP",
- "WATCHFRR",
- NULL,
-};
-
const char *zlog_priority[] =
{
"emergencies",
@@ -219,9 +196,9 @@ vzlog (int priority, const char *format, va_list args)
}
if (zl->instance)
- sprintf (proto_str, "%s[%d]: ", zlog_proto_names[zl->protocol], zl->instance);
+ sprintf (proto_str, "%s[%d]: ", zl->protoname, zl->instance);
else
- sprintf (proto_str, "%s: ", zlog_proto_names[zl->protocol]);
+ sprintf (proto_str, "%s: ", zl->protoname);
/* File output. */
if ((priority <= zl->maxlvl[ZLOG_DEST_FILE]) && zl->fp)
@@ -453,7 +430,7 @@ zlog_signal(int signo, const char *action
time(&now);
if (zlog_default)
{
- s = str_append(LOC,zlog_proto_names[zlog_default->protocol]);
+ s = str_append(LOC,zlog_default->protoname);
*s++ = ':';
*s++ = ' ';
msgstart = s;
@@ -735,8 +712,8 @@ memory_oom (size_t size, const char *name)
}
/* Open log stream */
-struct zlog *
-openzlog (const char *progname, zlog_proto_t protocol, u_short instance,
+void
+openzlog (const char *progname, const char *protoname, u_short instance,
int syslog_flags, int syslog_facility)
{
struct zlog *zl;
@@ -745,7 +722,7 @@ openzlog (const char *progname, zlog_proto_t protocol, u_short instance,
zl = XCALLOC(MTYPE_ZLOG, sizeof (struct zlog));
zl->ident = progname;
- zl->protocol = protocol;
+ zl->protoname = protoname;
zl->instance = instance;
zl->facility = syslog_facility;
zl->syslog_options = syslog_flags;
@@ -757,13 +734,14 @@ openzlog (const char *progname, zlog_proto_t protocol, u_short instance,
zl->default_lvl = LOG_DEBUG;
openlog (progname, syslog_flags, zl->facility);
-
- return zl;
+ zlog_default = zl;
}
void
-closezlog (struct zlog *zl)
+closezlog (void)
{
+ struct zlog *zl = zlog_default;
+
closelog();
if (zl->fp != NULL)
@@ -773,6 +751,7 @@ closezlog (struct zlog *zl)
XFREE(MTYPE_ZLOG, zl->filename);
XFREE (MTYPE_ZLOG, zl);
+ zlog_default = NULL;
}
/* Called from command.c. */
diff --git a/lib/log.h b/lib/log.h
index d0f8c0c3ac..3d887fdbbb 100644
--- a/lib/log.h
+++ b/lib/log.h
@@ -42,28 +42,6 @@
* please use LOG_ERR instead.
*/
-/*
- * This must be kept in the same order as
- * zlog_proto_names[]
- */
-typedef enum
-{
- ZLOG_NONE,
- ZLOG_DEFAULT,
- ZLOG_ZEBRA,
- ZLOG_RIP,
- ZLOG_BGP,
- ZLOG_OSPF,
- ZLOG_RIPNG,
- ZLOG_OSPF6,
- ZLOG_LDP,
- ZLOG_ISIS,
- ZLOG_PIM,
- ZLOG_NHRP,
- ZLOG_RFP,
- ZLOG_WATCHFRR,
-} zlog_proto_t;
-
/* If maxlvl is set to ZLOG_DISABLED, then no messages will be sent
to that logging destination. */
#define ZLOG_DISABLED (LOG_EMERG-1)
@@ -80,7 +58,7 @@ typedef enum
struct zlog
{
const char *ident; /* daemon name (first arg to openlog) */
- zlog_proto_t protocol;
+ const char *protoname;
u_short instance;
int maxlvl[ZLOG_NUM_DESTS]; /* maximum priority to send to associated
logging destination */
@@ -105,11 +83,11 @@ struct message
extern struct zlog *zlog_default;
/* Open zlog function */
-extern struct zlog *openzlog (const char *progname, zlog_proto_t protocol,
- u_short instance, int syslog_options, int syslog_facility);
+extern void openzlog (const char *progname, const char *protoname,
+ u_short instance, int syslog_options, int syslog_facility);
/* Close zlog function. */
-extern void closezlog (struct zlog *zl);
+extern void closezlog (void);
/* GCC have printf type attribute check. */
#ifdef __GNUC__
@@ -156,7 +134,6 @@ extern const char *mes_lookup (const struct message *meslist,
const char *no_item, const char *mesname);
extern const char *zlog_priority[];
-extern const char *zlog_proto_names[];
/* Safe version of strerror -- never returns NULL. */
extern const char *safe_strerror(int errnum);
diff --git a/lib/plist.c b/lib/plist.c
index 3ed5c8fc5c..37320c45d3 100644
--- a/lib/plist.c
+++ b/lib/plist.c
@@ -1176,7 +1176,7 @@ vty_show_prefix_entry (struct vty *vty, afi_t afi, struct prefix_list *plist,
/* Print the name of the protocol */
if (zlog_default)
- vty_out (vty, "%s: ", zlog_proto_names[zlog_default->protocol]);
+ vty_out (vty, "%s: ", zlog_default->protoname);
if (dtype == normal_display)
{
diff --git a/lib/routemap.c b/lib/routemap.c
index 78d4285243..b1a4c9fdef 100644
--- a/lib/routemap.c
+++ b/lib/routemap.c
@@ -991,7 +991,7 @@ vty_show_route_map_entry (struct vty *vty, struct route_map *map)
/* Print the name of the protocol */
if (zlog_default)
{
- vty_out (vty, "%s", zlog_proto_names[zlog_default->protocol]);
+ vty_out (vty, "%s", zlog_default->protoname);
if (zlog_default->instance)
vty_out (vty, " %d", zlog_default->instance);
}
@@ -1052,7 +1052,7 @@ vty_show_route_map (struct vty *vty, const char *name)
else
{
if (zlog_default)
- vty_out (vty, "%s", zlog_proto_names[zlog_default->protocol]);
+ vty_out (vty, "%s", zlog_default->protoname);
if (zlog_default && zlog_default->instance)
vty_out (vty, " %d", zlog_default->instance);
vty_out (vty, ": 'route-map %s' not found%s", name, VTY_NEWLINE);
diff --git a/lib/vty.c b/lib/vty.c
index 042c30757c..6501ca5cd8 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -458,9 +458,9 @@ vty_command (struct vty *vty, char *buf)
/* Get the name of the protocol if any */
if (zlog_default)
- protocolname = zlog_proto_names[zlog_default->protocol];
+ protocolname = zlog_default->protoname;
else
- protocolname = zlog_proto_names[ZLOG_NONE];
+ protocolname = "NONE";
#ifdef CONSUMED_TIME_CHECK
GETRUSAGE(&after);
diff --git a/ospf6d/ospf6_main.c b/ospf6d/ospf6_main.c
index 6c994189ee..b4d2cbe8d3 100644
--- a/ospf6d/ospf6_main.c
+++ b/ospf6d/ospf6_main.c
@@ -116,8 +116,7 @@ ospf6_exit (int status)
if (master)
thread_master_free (master);
- if (zlog_default)
- closezlog (zlog_default);
+ closezlog ();
exit (status);
}
diff --git a/tests/lib/cli/common_cli.c b/tests/lib/cli/common_cli.c
index 104352f516..5176df189e 100644
--- a/tests/lib/cli/common_cli.c
+++ b/tests/lib/cli/common_cli.c
@@ -52,7 +52,7 @@ static void vty_do_exit(void)
cmd_terminate ();
vty_terminate ();
thread_master_free (master);
- closezlog (zlog_default);
+ closezlog ();
log_memstats_stderr ("testcli");
exit (0);
@@ -70,8 +70,8 @@ main (int argc, char **argv)
/* master init. */
master = thread_master_create ();
- zlog_default = openzlog ("common-cli", ZLOG_NONE, 0,
- LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON);
+ openzlog("common-cli", "NONE", 0, LOG_CONS | LOG_NDELAY | LOG_PID,
+ LOG_DAEMON);
zlog_set_level (NULL, ZLOG_DEST_SYSLOG, ZLOG_DISABLED);
zlog_set_level (NULL, ZLOG_DEST_STDOUT, ZLOG_DISABLED);
zlog_set_level (NULL, ZLOG_DEST_MONITOR, LOG_DEBUG);
diff --git a/tests/lib/test_segv.c b/tests/lib/test_segv.c
index 1810c5f4b2..aa806c77c2 100644
--- a/tests/lib/test_segv.c
+++ b/tests/lib/test_segv.c
@@ -49,8 +49,7 @@ main (void)
master = thread_master_create ();
signal_init (master, array_size(sigs), sigs);
- zlog_default = openzlog("testsegv", ZLOG_NONE, 0,
- LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON);
+ openzlog("testsegv", "NONE", 0, LOG_CONS | LOG_NDELAY | LOG_PID, LOG_DAEMON);
zlog_set_level (NULL, ZLOG_DEST_SYSLOG, ZLOG_DISABLED);
zlog_set_level (NULL, ZLOG_DEST_STDOUT, LOG_DEBUG);
zlog_set_level (NULL, ZLOG_DEST_MONITOR, ZLOG_DISABLED);
diff --git a/tests/lib/test_sig.c b/tests/lib/test_sig.c
index 4a04240303..641156808a 100644
--- a/tests/lib/test_sig.c
+++ b/tests/lib/test_sig.c
@@ -64,9 +64,8 @@ main (void)
{
master = thread_master_create ();
signal_init (master, array_size(sigs), sigs);
-
- zlog_default = openzlog("testsig", ZLOG_NONE, 0,
- LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON);
+
+ openzlog("testsig", "NONE", 0, LOG_CONS | LOG_NDELAY | LOG_PID, LOG_DAEMON);
zlog_set_level (NULL, ZLOG_DEST_SYSLOG, ZLOG_DISABLED);
zlog_set_level (NULL, ZLOG_DEST_STDOUT, LOG_DEBUG);
zlog_set_level (NULL, ZLOG_DEST_MONITOR, ZLOG_DISABLED);
diff --git a/zebra/main.c b/zebra/main.c
index 7177fe329f..e951ca6941 100644
--- a/zebra/main.c
+++ b/zebra/main.c
@@ -168,8 +168,7 @@ sigint (void)
work_queue_free (zebrad.lsp_process_q);
meta_queue_free (zebrad.mq);
thread_master_free (zebrad.master);
- if (zlog_default)
- closezlog (zlog_default);
+ closezlog ();
exit (0);
}
diff --git a/zebra/test_main.c b/zebra/test_main.c
index 43149318d1..2996b45464 100644
--- a/zebra/test_main.c
+++ b/zebra/test_main.c
@@ -222,8 +222,7 @@ main (int argc, char **argv)
/* preserve my name */
progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]);
- zlog_default = openzlog (progname, ZLOG_ZEBRA, 0,
- LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON);
+ openzlog(progname, "ZEBRA", 0, LOG_CONS | LOG_NDELAY | LOG_PID, LOG_DAEMON);
while (1)
{