]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/log.c
Merge branch 'frr/pull/822' ("EVPN fixes")
[mirror_frr.git] / lib / log.c
index 68f172cdf9165e32429f7a9926f6994fc64574a9..5c89e7080eafaef5b5955b2374028f20567a8228 100644 (file)
--- a/lib/log.c
+++ b/lib/log.c
@@ -41,6 +41,7 @@ DEFINE_MTYPE_STATIC(LIB, ZLOG, "Logging")
 static int logfile_fd = -1; /* Used in signal handler. */
 
 struct zlog *zlog_default = NULL;
+bool zlog_startup_stderr = true;
 
 const char *zlog_priority[] = {
        "emergencies",   "alerts",      "critical",  "errors", "warnings",
@@ -172,6 +173,25 @@ static void time_print(FILE *fp, struct timestamp_control *ctl)
 }
 
 
+static void vzlog_file(struct zlog *zl, struct timestamp_control *tsctl,
+                      const char *proto_str, int record_priority,
+                      int priority, FILE *fp, const char *format,
+                      va_list args)
+{
+       va_list ac;
+
+       time_print(fp, tsctl);
+       if (record_priority)
+               fprintf(fp, "%s: ", zlog_priority[priority]);
+
+       fprintf(fp, "%s", proto_str);
+       va_copy(ac, args);
+       vfprintf(fp, format, ac);
+       va_end(ac);
+       fprintf(fp, "\n");
+       fflush(fp);
+}
+
 /* va_list version of zlog. */
 void vzlog(int priority, const char *format, va_list args)
 {
@@ -210,32 +230,21 @@ void vzlog(int priority, const char *format, va_list args)
                sprintf(proto_str, "%s: ", zl->protoname);
 
        /* File output. */
-       if ((priority <= zl->maxlvl[ZLOG_DEST_FILE]) && zl->fp) {
-               va_list ac;
-               time_print(zl->fp, &tsctl);
-               if (zl->record_priority)
-                       fprintf(zl->fp, "%s: ", zlog_priority[priority]);
-               fprintf(zl->fp, "%s", proto_str);
-               va_copy(ac, args);
-               vfprintf(zl->fp, format, ac);
-               va_end(ac);
-               fprintf(zl->fp, "\n");
-               fflush(zl->fp);
-       }
-
-       /* stdout output. */
-       if (priority <= zl->maxlvl[ZLOG_DEST_STDOUT]) {
-               va_list ac;
-               time_print(stdout, &tsctl);
-               if (zl->record_priority)
-                       fprintf(stdout, "%s: ", zlog_priority[priority]);
-               fprintf(stdout, "%s", proto_str);
-               va_copy(ac, args);
-               vfprintf(stdout, format, ac);
-               va_end(ac);
-               fprintf(stdout, "\n");
-               fflush(stdout);
-       }
+       if ((priority <= zl->maxlvl[ZLOG_DEST_FILE]) && zl->fp)
+               vzlog_file(zl, &tsctl, proto_str, zl->record_priority,
+                               priority, zl->fp, format, args);
+
+       /* fixed-config logging to stderr while we're stating up & haven't
+        * daemonized / reached mainloop yet
+        *
+        * note the "else" on stdout output -- we don't want to print the same
+        * message to both stderr and stdout. */
+       if (zlog_startup_stderr && priority <= LOG_WARNING)
+               vzlog_file(zl, &tsctl, proto_str, 1,
+                               priority, stderr, format, args);
+       else if (priority <= zl->maxlvl[ZLOG_DEST_STDOUT])
+               vzlog_file(zl, &tsctl, proto_str, zl->record_priority,
+                               priority, stdout, format, args);
 
        /* Terminal monitor. */
        if (priority <= zl->maxlvl[ZLOG_DEST_MONITOR])
@@ -411,7 +420,7 @@ void zlog_signal(int signo, const char *action
                 ,
                 siginfo_t *siginfo, void *program_counter
 #endif
-)
+                )
 {
        time_t now;
        char buf[sizeof("DEFAULT: Received signal S at T (si_addr 0xP, PC 0xP); aborting...")
@@ -474,7 +483,7 @@ void zlog_signal(int signo, const char *action
 #else
                               NULL
 #endif
-       );
+                              );
 
        s = buf;
        struct thread *tc;
@@ -857,6 +866,7 @@ static const struct zebra_desc_table command_types[] = {
        DESC_ENTRY(ZEBRA_INTERFACE_ADDRESS_DELETE),
        DESC_ENTRY(ZEBRA_INTERFACE_UP),
        DESC_ENTRY(ZEBRA_INTERFACE_DOWN),
+       DESC_ENTRY(ZEBRA_INTERFACE_SET_MASTER),
        DESC_ENTRY(ZEBRA_IPV4_ROUTE_ADD),
        DESC_ENTRY(ZEBRA_IPV4_ROUTE_DELETE),
        DESC_ENTRY(ZEBRA_IPV6_ROUTE_ADD),
@@ -907,6 +917,7 @@ static const struct zebra_desc_table command_types[] = {
        DESC_ENTRY(ZEBRA_GET_LABEL_CHUNK),
        DESC_ENTRY(ZEBRA_RELEASE_LABEL_CHUNK),
        DESC_ENTRY(ZEBRA_ADVERTISE_ALL_VNI),
+       DESC_ENTRY(ZEBRA_ADVERTISE_DEFAULT_GW),
        DESC_ENTRY(ZEBRA_VNI_ADD),
        DESC_ENTRY(ZEBRA_VNI_DEL),
        DESC_ENTRY(ZEBRA_REMOTE_VTEP_ADD),
@@ -915,6 +926,11 @@ static const struct zebra_desc_table command_types[] = {
        DESC_ENTRY(ZEBRA_MACIP_DEL),
        DESC_ENTRY(ZEBRA_REMOTE_MACIP_ADD),
        DESC_ENTRY(ZEBRA_REMOTE_MACIP_DEL),
+       DESC_ENTRY(ZEBRA_PW_ADD),
+       DESC_ENTRY(ZEBRA_PW_DELETE),
+       DESC_ENTRY(ZEBRA_PW_SET),
+       DESC_ENTRY(ZEBRA_PW_UNSET),
+       DESC_ENTRY(ZEBRA_PW_STATUS_UPDATE),
 };
 #undef DESC_ENTRY
 
@@ -1063,9 +1079,10 @@ void zlog_hexdump(const void *mem, unsigned int len)
                                                 printing */
                                        s += sprintf(s, " ");
 
-                               else if (isprint((int)((const char *)mem)
-                                                        [j])) /* printable char
-                                                               */
+                               else if (
+                                       isprint((int)((const char *)mem)
+                                                       [j])) /* printable char
+                                                                */
                                        s += sprintf(
                                                s, "%c",
                                                0xFF & ((const char *)mem)[j]);