forked from Mirror/frr
lib: detangle protocol name/instance from logging
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
parent
4d2d73c281
commit
b85120bcb3
|
@ -28,6 +28,7 @@
|
|||
#include "buffer.h"
|
||||
#include "log.h"
|
||||
#include "routemap.h"
|
||||
#include "libfrr.h"
|
||||
|
||||
DEFINE_MTYPE_STATIC(LIB, ACCESS_LIST, "Access List")
|
||||
DEFINE_MTYPE_STATIC(LIB, ACCESS_LIST_STR, "Access List Str")
|
||||
|
@ -1696,7 +1697,7 @@ filter_show (struct vty *vty, const char *name, afi_t afi)
|
|||
return 0;
|
||||
|
||||
/* Print the name of the protocol */
|
||||
vty_out(vty, "%s:%s", zlog_protoname(), VTY_NEWLINE);
|
||||
vty_out(vty, "%s:%s", frr_protoname, VTY_NEWLINE);
|
||||
|
||||
for (access = master->num.head; access; access = access->next)
|
||||
{
|
||||
|
|
10
lib/libfrr.c
10
lib/libfrr.c
|
@ -36,6 +36,9 @@ const char frr_sysconfdir[] = SYSCONFDIR;
|
|||
const char frr_vtydir[] = DAEMON_VTY_DIR;
|
||||
const char frr_moduledir[] = MODULE_PATH;
|
||||
|
||||
char frr_protoname[] = "NONE";
|
||||
char frr_protonameinst[] = "NONE";
|
||||
|
||||
char config_default[256];
|
||||
static char pidfile_default[256];
|
||||
static char vtypath_default[256];
|
||||
|
@ -164,6 +167,9 @@ void frr_preinit(struct frr_daemon_info *daemon, int argc, char **argv)
|
|||
frr_sysconfdir, di->name);
|
||||
snprintf(pidfile_default, sizeof(pidfile_default), "%s/%s.pid",
|
||||
frr_vtydir, di->name);
|
||||
|
||||
strlcpy(frr_protoname, di->logname, sizeof(frr_protoname));
|
||||
strlcpy(frr_protonameinst, di->logname, sizeof(frr_protonameinst));
|
||||
}
|
||||
|
||||
void frr_opt_add(const char *optstr, const struct option *longopts,
|
||||
|
@ -337,6 +343,10 @@ struct thread_master *frr_init(void)
|
|||
|
||||
srandom(time(NULL));
|
||||
|
||||
if (di->instance)
|
||||
snprintf(frr_protonameinst, sizeof(frr_protonameinst),
|
||||
"%s[%u]", di->logname, di->instance);
|
||||
|
||||
openzlog (di->progname, di->logname, di->instance,
|
||||
LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON);
|
||||
#if defined(HAVE_CUMULUS)
|
||||
|
|
|
@ -110,4 +110,7 @@ extern const char frr_sysconfdir[];
|
|||
extern const char frr_vtydir[];
|
||||
extern const char frr_moduledir[];
|
||||
|
||||
extern char frr_protoname[];
|
||||
extern char frr_protonameinst[];
|
||||
|
||||
#endif /* _ZEBRA_FRR_H */
|
||||
|
|
|
@ -763,12 +763,6 @@ closezlog (void)
|
|||
zlog_default = NULL;
|
||||
}
|
||||
|
||||
const char *
|
||||
zlog_protoname (void)
|
||||
{
|
||||
return zlog_default ? zlog_default->protoname : "NONE";
|
||||
}
|
||||
|
||||
/* Called from command.c. */
|
||||
void
|
||||
zlog_set_level (zlog_dest_t dest, int log_level)
|
||||
|
|
|
@ -69,8 +69,6 @@ extern void openzlog (const char *progname, const char *protoname,
|
|||
/* Close zlog function. */
|
||||
extern void closezlog (void);
|
||||
|
||||
extern const char *zlog_protoname (void);
|
||||
|
||||
/* GCC have printf type attribute check. */
|
||||
#ifdef __GNUC__
|
||||
#define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b)))
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "log.h"
|
||||
#include "routemap.h"
|
||||
#include "lib/json.h"
|
||||
#include "libfrr.h"
|
||||
|
||||
#include "plist_int.h"
|
||||
|
||||
|
@ -1174,7 +1175,7 @@ vty_show_prefix_entry (struct vty *vty, afi_t afi, struct prefix_list *plist,
|
|||
struct prefix_list_entry *pentry;
|
||||
|
||||
/* Print the name of the protocol */
|
||||
vty_out(vty, "%s: ", zlog_protoname());
|
||||
vty_out(vty, "%s: ", frr_protoname);
|
||||
|
||||
if (dtype == normal_display)
|
||||
{
|
||||
|
|
|
@ -28,8 +28,8 @@
|
|||
#include "routemap.h"
|
||||
#include "command.h"
|
||||
#include "log.h"
|
||||
#include "log_int.h"
|
||||
#include "hash.h"
|
||||
#include "libfrr.h"
|
||||
|
||||
DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP, "Route map")
|
||||
DEFINE_MTYPE( LIB, ROUTE_MAP_NAME, "Route map name")
|
||||
|
@ -989,14 +989,7 @@ vty_show_route_map_entry (struct vty *vty, struct route_map *map)
|
|||
struct route_map_index *index;
|
||||
struct route_map_rule *rule;
|
||||
|
||||
/* Print the name of the protocol */
|
||||
if (zlog_default)
|
||||
{
|
||||
vty_out (vty, "%s", zlog_protoname());
|
||||
if (zlog_default->instance)
|
||||
vty_out (vty, " %d", zlog_default->instance);
|
||||
}
|
||||
vty_out (vty, ":%s", VTY_NEWLINE);
|
||||
vty_out (vty, "%s:%s", frr_protonameinst, VTY_NEWLINE);
|
||||
|
||||
for (index = map->head; index; index = index->next)
|
||||
{
|
||||
|
@ -1052,10 +1045,8 @@ vty_show_route_map (struct vty *vty, const char *name)
|
|||
}
|
||||
else
|
||||
{
|
||||
vty_out (vty, "%s", zlog_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);
|
||||
vty_out (vty, "%s: 'route-map %s' not found%s", frr_protonameinst,
|
||||
name, VTY_NEWLINE);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "vty.h"
|
||||
#include "privs.h"
|
||||
#include "network.h"
|
||||
#include "libfrr.h"
|
||||
|
||||
#include <arpa/telnet.h>
|
||||
#include <termios.h>
|
||||
|
@ -456,7 +457,7 @@ vty_command (struct vty *vty, char *buf)
|
|||
ret = cmd_execute_command (vline, vty, NULL, 0);
|
||||
|
||||
/* Get the name of the protocol if any */
|
||||
protocolname = zlog_protoname();
|
||||
protocolname = frr_protoname;
|
||||
|
||||
#ifdef CONSUMED_TIME_CHECK
|
||||
GETRUSAGE(&after);
|
||||
|
|
Loading…
Reference in a new issue