2004-12-07 Andrew J. Schorr <ajschorr@alumni.princeton.edu>

	* bgp_main.c: (main) The 2nd argument to openzlog has been removed.
	* isis_main.c: (main) The 2nd argument to openzlog has been removed.
	* ospf6_main.c: (main) The 2nd argument to openzlog has been removed.
	  Note that stdout logging will no longer be enabled by default when
	  not running as a daemon.
	* ospf_main.c: (main) The 2nd argument to openzlog has been removed.
	* rip_main.c: (main) The 2nd argument to openzlog has been removed.
	* ripng_main.c: (main) The 2nd argument to openzlog has been removed.
	* main.c: (main) The 2nd argument to openzlog has been removed.
	  So stdout logging will no longer be enabled by default.
	* irdp_main.c: (irdp_finish) Reduce severity of shutdown message
	  from LOG_WARNING to LOG_INFO.
	* vtysh.c: Make several functions static instead of global.
	  Added several commands to support destination-specific logging levels.
	  (vtysh_completion) This function is unused, so comment it out.
	* basic.texi: Document new logging features.  Separate basic config
	  commands from basic VTY commands.
	* log.h: Replace struct zlog flags and maskpri fields with maxlvl
	  array to support individual logging levels for each destination.
	  Remove the 2nd argument to openzlog since the default logging config
	  should be standardized inside the library.  Replaced the
	  zlog_set_flag and zlog_reset_flag functions with zlog_set_level.
	  And zlog_set_file now requires an additional log_level argument.
	  Declare zlog_proto_names for use inside command.c in the
	  "show logging" command.  Added defines useful for command
	  construction.
	* log.c: (vzlog) Decide where to send the message based on the
	  individual logging levels configured for each destination.
	  Remove support for ZLOG_STDERR since it was never actually used.
	  Support record-priority for terminal monitors.
	  (zlog_signal,zlog_backtrace_sigsafe) Support destination-specific
	  logging levels.  Remove stderr support (was never used).  Added
	  support for terminal monitor logging.
	  (_zlog_assert_failed) Increase message severity to LOG_EMERG.
	  (openzlog) Remove 2nd argument since default config should be
	  standardized in library.  By default, terminal monitoring
	  is set to debug, and all other logging is disabled.
	  (zlog_set_flag,zlog_reset_flag) Removed.
	  (zlog_set_level) New function to replace zlog_set_flag and
	  zlog_reset_flag.  Supports destination-specific logging levels.
	  (zlog_set_file,zlog_reset_file) Support file-specific logging level.
	  (zlog_rotate) Log an error message if fopen fails, and support
	  new file-specific logging level.
	* command.h: Change DEFUN_CMD_FUNC_DECL and DEFUN_CMD_FUNC_TEXT so that
	  command functions will be static instead of global.  Remove
	  declarations for config_exit and config_help.  Define new macros
	  DEFUNSH_ATTR, DEFUNSH_HIDDEN, and DEFUNSH_DEPRECATED so we can
	  have deprecated commands in vtysh.  Similarly, for completeness,
	  define macros ALIAS_SH, ALIAS_SH_HIDDEN, and ALIAS_SH_DEPRECATED.
	  Also, fix bug in ALIAS_ATTR macro (didn't matter because it
	  was never used).
	* command.c: Make many functions static instead of global.
	  (facility_name,facility_match,level_match) New functions
	  to support enhanced destination-specific logging levels.
	  (config_write_host) Support new destination-specific logging levels.
	  (config_logmsg) Added new "logmsg" command to help test logging
	  system.
	  (show_logging) Added "show logging" command to show the current
	  configuration of the logging system.
	  (config_log_stdout_level) Support explicit stdout logging level.
	  (no_config_log_stdout) Now takes optional LEVEL arg.
	  (config_log_monitor,config_log_monitor_level,no_config_log_monitor)
	  New commands creating new "log monitor" commands to set terminal
	  monitoring log level.
	  (config_log_file_level) Support explicit file logging level.
	  (config_log_syslog_level) Support explicit syslog logging level.
	  (config_log_facility,no_config_log_facility) Implement new
	  "log facility" command.
	  (cmd_init) Add hooks for new commands: "show logging", "logmsg",
	  "log stdout <level>", "log monitor", "log monitor <level>",
	  "no log monitor", "log file <filename> <level>",
	  "no log file <filename> <level>", "log syslog <level>",
	  "log facility", and "no log facility".
	* vty.h: Added a "level" argument to vty_log so it can support
	  "log record-priority".  Declare new function vty_log_fixed for
	  use in signal handlers.
	* vty.c: (vty_log,vty_log_out) Added a "level" argument to support
	  "log record-priority" for vty terminal monitors.
	  (vty_down_level) Use config_exit_cmd.func instead of calling
	  config_exit directly (since command functions will now be static
	  instead of global).
	  (vty_log_fixed) New function to send terminal monitor messages
	  from inside a signal handler.
diff --git a/lib/log.h b/lib/log.h
index 26ff902..1f9f23c 100644
--- a/lib/log.h
+++ b/lib/log.h
@@ -1,4 +1,7 @@
-/* Zebra logging funcions.
+/*
+ * $Id: log.h,v 1.14 2004/12/07 15:39:32 ajs Exp $
+ *
+ * Zebra logging funcions.
  * Copyright (C) 1997, 1998, 1999 Kunihiro Ishiguro
  *
  * This file is part of GNU Zebra.
@@ -40,12 +43,6 @@
  * please use LOG_ERR instead.
  */
 
-#define ZLOG_NOLOG              0x00
-#define ZLOG_FILE		0x01
-#define ZLOG_SYSLOG		0x02
-#define ZLOG_STDOUT             0x04
-#define ZLOG_STDERR             0x08
-
 typedef enum 
 {
   ZLOG_NONE,
@@ -60,14 +57,28 @@
   ZLOG_MASC
 } 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)
+
+typedef enum
+{
+  ZLOG_DEST_SYSLOG = 0,
+  ZLOG_DEST_STDOUT,
+  ZLOG_DEST_MONITOR,
+  ZLOG_DEST_FILE
+} zlog_dest_t;
+#define ZLOG_NUM_DESTS		(ZLOG_DEST_FILE+1)
+
 struct zlog 
 {
   const char *ident;	/* daemon name (first arg to openlog) */
   zlog_proto_t protocol;
-  int flags;		/* mask indicating which destinations to log to */
+  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 maskpri;		/* discard messages with priority > maskpri */
   int facility;		/* as per syslog facility */
   int record_priority;	/* should messages logged through stdio include the
   			   priority of the message? */
@@ -85,7 +96,8 @@
 extern struct zlog *zlog_default;
 
 /* Open zlog function */
-struct zlog *openzlog (const char *, int, zlog_proto_t, int, int);
+struct zlog *openzlog (const char *progname, zlog_proto_t protocol,
+		       int syslog_options, int syslog_facility);
 
 /* Close zlog function. */
 void closezlog (struct zlog *zl);
@@ -114,12 +126,15 @@
 void plog_notice (struct zlog *, const char *format, ...);
 void plog_debug (struct zlog *, const char *format, ...);
 
-/* Set zlog flags. */
-void zlog_set_flag (struct zlog *zl, int flags);
-void zlog_reset_flag (struct zlog *zl, int flags);
+/* Set logging level for the given destination.  If the log_level
+   argument is ZLOG_DISABLED, then the destination is disabled.
+   This function should not be used for file logging (use zlog_set_file
+   or zlog_reset_file instead). */
+void zlog_set_level (struct zlog *zl, zlog_dest_t, int log_level);
 
-/* Set zlog filename. */
-int zlog_set_file (struct zlog *zl, const char *filename);
+/* Set logging to the given filename at the specified level. */
+int zlog_set_file (struct zlog *zl, const char *filename, int log_level);
+/* Disable file logging. */
 int zlog_reset_file (struct zlog *zl);
 
 /* Rotate log. */
@@ -132,6 +147,7 @@
 const char *mes_lookup (struct message *meslist, int max, int index);
 
 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);
@@ -147,4 +163,40 @@
    up the state of zlog file pointers. */
 extern void zlog_backtrace_sigsafe(int priority);
 
+/* Defines for use in command construction: */
+
+#define LOG_LEVELS "(emergencies|alerts|critical|errors|warnings|notifications|informational|debugging)"
+
+#define LOG_LEVEL_DESC \
+  "System is unusable\n" \
+  "Immediate action needed\n" \
+  "Critical conditions\n" \
+  "Error conditions\n" \
+  "Warning conditions\n" \
+  "Normal but significant conditions\n" \
+  "Informational messages\n" \
+  "Debugging messages\n"
+
+#define LOG_FACILITIES "(kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7)"
+
+#define LOG_FACILITY_DESC \
+       "Kernel\n" \
+       "User process\n" \
+       "Mail system\n" \
+       "System daemons\n" \
+       "Authorization system\n" \
+       "Syslog itself\n" \
+       "Line printer system\n" \
+       "USENET news\n" \
+       "Unix-to-Unix copy system\n" \
+       "Cron/at facility\n" \
+       "Local use\n" \
+       "Local use\n" \
+       "Local use\n" \
+       "Local use\n" \
+       "Local use\n" \
+       "Local use\n" \
+       "Local use\n" \
+       "Local use\n"
+
 #endif /* _ZEBRA_LOG_H */