diff --git a/bgpd/bgp_updgrp.h b/bgpd/bgp_updgrp.h index 6ab384369c..8f3e27bc84 100644 --- a/bgpd/bgp_updgrp.h +++ b/bgpd/bgp_updgrp.h @@ -249,7 +249,6 @@ struct update_subgroup u_int32_t merge_checks_triggered; uint64_t id; - struct zlog *log; u_int16_t sflags; diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c index 956005a1bf..c52026e8ef 100644 --- a/bgpd/rfapi/rfapi_vty.c +++ b/bgpd/rfapi/rfapi_vty.c @@ -29,6 +29,7 @@ #include "lib/memory.h" #include "lib/routemap.h" #include "lib/log.h" +#include "lib/log_int.h" #include "lib/linklist.h" #include "lib/command.h" diff --git a/ldpd/log.c b/ldpd/log.c index 3bad86499d..407668bb03 100644 --- a/ldpd/log.c +++ b/ldpd/log.c @@ -24,6 +24,7 @@ #include "log.h" #include +#include #include "mpls.h" static const char * const procnames[] = { diff --git a/lib/Makefile.am b/lib/Makefile.am index b9f318cedc..1a8c7af42b 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -58,7 +58,8 @@ pkginclude_HEADERS = \ # end noinst_HEADERS = \ - plist_int.h + plist_int.h \ + log_int.h noinst_PROGRAMS = grammar_sandbox diff --git a/lib/command.c b/lib/command.c index 597e5a06c8..bfff581d9b 100644 --- a/lib/command.c +++ b/lib/command.c @@ -30,6 +30,7 @@ #include "memory.h" #include "log.h" +#include "log_int.h" #include #include "thread.h" #include "vector.h" diff --git a/lib/filter.c b/lib/filter.c index 58138b2978..fd73d4de73 100644 --- a/lib/filter.c +++ b/lib/filter.c @@ -1697,9 +1697,7 @@ filter_show (struct vty *vty, const char *name, afi_t afi) return 0; /* Print the name of the protocol */ - if (zlog_default) - vty_out (vty, "%s:%s", - zlog_default->protoname, VTY_NEWLINE); + vty_out(vty, "%s:%s", zlog_protoname(), VTY_NEWLINE); for (access = master->num.head; access; access = access->next) { diff --git a/lib/log.c b/lib/log.c index bf4d3726d3..0fd9621f37 100644 --- a/lib/log.c +++ b/lib/log.c @@ -26,6 +26,7 @@ #include "zclient.h" #include "log.h" +#include "log_int.h" #include "memory.h" #include "command.h" #ifndef SUNOS_5 @@ -752,6 +753,12 @@ 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) diff --git a/lib/log.h b/lib/log.h index 889a462fe0..8a65bbbf51 100644 --- a/lib/log.h +++ b/lib/log.h @@ -55,23 +55,6 @@ typedef enum } zlog_dest_t; #define ZLOG_NUM_DESTS (ZLOG_DEST_FILE+1) -struct zlog -{ - const char *ident; /* daemon name (first arg to openlog) */ - const char *protoname; - u_short instance; - int maxlvl[ZLOG_NUM_DESTS]; /* maximum priority to send to associated - logging destination */ - int default_lvl; /* maxlvl to use if none is specified */ - FILE *fp; - char *filename; - int facility; /* as per syslog facility */ - int record_priority; /* should messages logged through stdio include the - priority of the message? */ - int syslog_options; /* 2nd arg to openlog */ - int timestamp_precision; /* # of digits of subsecond precision */ -}; - /* Message structure. */ struct message { @@ -79,9 +62,6 @@ struct message const char *str; }; -/* Default logging strucutre. */ -extern struct zlog *zlog_default; - /* Open zlog function */ extern void openzlog (const char *progname, const char *protoname, u_short instance, int syslog_options, int syslog_facility); @@ -89,6 +69,8 @@ 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))) @@ -96,12 +78,7 @@ extern void closezlog (void); #define PRINTF_ATTRIBUTE(a,b) #endif /* __GNUC__ */ -/* Generic function for zlog. */ -extern void zlog (int priority, const char *format, ...) - PRINTF_ATTRIBUTE(2, 3); - /* Handy zlog functions. */ -extern void vzlog (int priority, const char *format, va_list args); extern void zlog_err (const char *format, ...) PRINTF_ATTRIBUTE(1, 2); extern void zlog_warn (const char *format, ...) PRINTF_ATTRIBUTE(1, 2); extern void zlog_info (const char *format, ...) PRINTF_ATTRIBUTE(1, 2); @@ -133,8 +110,6 @@ extern const char *mes_lookup (const struct message *meslist, int max, int index, const char *no_item, const char *mesname); -extern const char *zlog_priority[]; - /* Safe version of strerror -- never returns NULL. */ extern const char *safe_strerror(int errnum); diff --git a/lib/log_int.h b/lib/log_int.h new file mode 100644 index 0000000000..c21d723ac6 --- /dev/null +++ b/lib/log_int.h @@ -0,0 +1,57 @@ +/* + * Zebra logging funcions. + * Copyright (C) 1997, 1998, 1999 Kunihiro Ishiguro + * + * This file is part of GNU Zebra. + * + * GNU Zebra is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * GNU Zebra is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Zebra; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef _ZEBRA_LOG_PRIVATE_H +#define _ZEBRA_LOG_PRIVATE_H + +#include "log.h" + +struct zlog +{ + const char *ident; /* daemon name (first arg to openlog) */ + const char *protoname; + u_short instance; + int maxlvl[ZLOG_NUM_DESTS]; /* maximum priority to send to associated + logging destination */ + int default_lvl; /* maxlvl to use if none is specified */ + FILE *fp; + char *filename; + int facility; /* as per syslog facility */ + int record_priority; /* should messages logged through stdio include the + priority of the message? */ + int syslog_options; /* 2nd arg to openlog */ + int timestamp_precision; /* # of digits of subsecond precision */ +}; + +/* Default logging strucutre. */ +extern struct zlog *zlog_default; + +extern const char *zlog_priority[]; + +/* Generic function for zlog. */ +extern void vzlog (int priority, const char *format, va_list args); +extern void zlog (int priority, const char *format, ...) + PRINTF_ATTRIBUTE(2, 3); + +#endif /* _ZEBRA_LOG_PRIVATE_H */ + + diff --git a/lib/plist.c b/lib/plist.c index 37320c45d3..3714969696 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -1175,8 +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 */ - if (zlog_default) - vty_out (vty, "%s: ", zlog_default->protoname); + vty_out(vty, "%s: ", zlog_protoname()); if (dtype == normal_display) { diff --git a/lib/routemap.c b/lib/routemap.c index b1a4c9fdef..1647ac3668 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -28,6 +28,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "routemap.h" #include "command.h" #include "log.h" +#include "log_int.h" #include "hash.h" DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP, "Route map") @@ -991,7 +992,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_default->protoname); + vty_out (vty, "%s", zlog_protoname()); if (zlog_default->instance) vty_out (vty, " %d", zlog_default->instance); } @@ -1051,8 +1052,7 @@ vty_show_route_map (struct vty *vty, const char *name) } else { - if (zlog_default) - vty_out (vty, "%s", zlog_default->protoname); + 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); diff --git a/lib/vty.c b/lib/vty.c index 6501ca5cd8..4d34fead8b 100644 --- a/lib/vty.c +++ b/lib/vty.c @@ -457,10 +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 */ - if (zlog_default) - protocolname = zlog_default->protoname; - else - protocolname = "NONE"; + protocolname = zlog_protoname(); #ifdef CONSUMED_TIME_CHECK GETRUSAGE(&after); diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 2dba64c5bd..f9734fdf7d 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -28,6 +28,7 @@ #include "zebra_memory.h" #include "command.h" #include "log.h" +#include "log_int.h" #include "sockunion.h" #include "linklist.h" #include "thread.h"