]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 1681] sntp logging cleanup.
authorDave Hart <hart@ntp.org>
Tue, 9 Nov 2010 05:52:27 +0000 (05:52 +0000)
committerDave Hart <hart@ntp.org>
Tue, 9 Nov 2010 05:52:27 +0000 (05:52 +0000)
bk: 4cd8e19b_yAqsvcAknXzOETZR4nhpw

ChangeLog
sntp/kod_management.c
sntp/log.c
sntp/log.h
sntp/main.c
sntp/networking.c

index a54f5534f1b6ae7fa488ac7fe9c9b0bf1261d122..2a8477d79aa5fa0e51e10d3156b3f25a4349ae8e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 ---
 
 * [Bug 1574] sntp:set_time doesn't set tv_usec correctly.
+* [Bug 1681] sntp logging cleanup.
 * [Bug 1683] Interface binding does not seem to work as intended.
 * [Bug 1691] Use first NMEA sentence each second.
 * [Bug 1709] ntpdate ignores replies with equal receive and transmit
index 878a2a0c1d98670e77f014918dc3c061ffc1f187..4bdb4e8d93cccc543c069d0e13be0c560f84c56f 100644 (file)
@@ -148,7 +148,7 @@ write_kod_db(void)
 #ifdef DEBUG
                debug_msg(msg);
 #endif
-               log_msg(msg, 2);
+               log_msg(msg, LOG_WARNING | LOG_CONS);
 
                return;
        }
@@ -199,7 +199,7 @@ kod_init_kod_db(
                debug_msg(msg);
                printf("%s\n", msg);
 #endif
-               log_msg(msg, 2);
+               log_msg(msg, LOG_WARNING | LOG_CONS);
 
                return;
        }
@@ -231,7 +231,7 @@ kod_init_kod_db(
                                                debug_msg(msg);
                                                printf("%s\n", msg);
        #endif
-                                               log_msg(msg, 1);
+                                               log_msg(msg, LOG_DEBUG | LOG_CONS);
                                        }
                                        fclose(db_s);
                                        return;
@@ -297,7 +297,7 @@ kod_init_kod_db(
 #ifdef DEBUG
                debug_msg(msg);
 #endif
-               log_msg(msg, 2);
+               log_msg(msg, LOG_WARNING | LOG_CONS);
                fclose(db_s);
 
                return;
index c6bfe222885fdbd714d75162cf77a65ef137ac20..52d9fd25d5fbf882c12713a6541dfabc78ba29d5 100644 (file)
@@ -7,29 +7,14 @@ int filelog = 0;
 FILE *log_file;
 
 
-void log_msg(char *message, char type) {
-       if(init) {
+void log_msg(char *message, int type) {
+       if (init) {
                time_t cur_time = time(NULL);
                char *timestamp = ctime(&cur_time);
 
                fprintf(log_file, "%s: %s\n", timestamp, message);
                fflush(log_file);
-       }
-       else {
-               switch(type) {
-                       case 0:
-                               type = LOG_CONS;
-                               break;
-                       
-                       case 1:
-                               type = LOG_DEBUG | LOG_CONS;
-                               break;
-       
-                       case 2: 
-                               type = LOG_WARNING | LOG_CONS;
-                               break;
-               }
-
+       } else {
                syslog(type, message);
        }
 }
index 328d96184270390695008b566346d598c8d441f8..b35d5e40b07da962caaf3f823714329ba1dcc23b 100644 (file)
@@ -10,7 +10,7 @@
 #include <time.h>
 
 
-void log_msg(char *message, char type);
+void log_msg(char *message, int type);
 void debug_msg(char *message);
 
 void init_log(const char *logfile);
index 3c8101124a80edd9a4233bd2994af42318f86814..23ccd4c121ae8b2a3fbdbb0113daf316e09d5ff7 100644 (file)
@@ -85,8 +85,6 @@ sntp_main (
                        ai_fam_pref = AF_INET6;
        }
 
-       log_msg("Started sntp", 0);
-
        optct = optionProcess(&sntpOptions, argc, argv);
        argc -= optct;
        argv += optct; 
@@ -97,6 +95,8 @@ sntp_main (
        if (HAVE_OPT(FILELOG))
                init_log(OPT_ARG(FILELOG));
 
+       log_msg("Started sntp", LOG_CONS);
+
        /* 
         * If there's a specified KOD file init KOD system.  If not use
         * default file.  For embedded systems with no writable
@@ -275,7 +275,7 @@ on_wire (
                                 "Received a KOD packet with code %c%c%c%c from %s, demobilizing all connections", 
                                 ref[0], ref[1], ref[2], ref[3],
                                 hostname);
-                       log_msg(log_str, 2);
+                       log_msg(log_str, LOG_WARNING | LOG_CONS);
                        free(log_str);
                        break;
 
@@ -366,7 +366,7 @@ on_wire (
        getnameinfo(host->ai_addr, host->ai_addrlen, addr_buf, sizeof(addr_buf), NULL, 0, NI_NUMERICHOST);
 
        snprintf(logmsg, sizeof(logmsg), "Received no useable packet from %s!", addr_buf);
-       log_msg(logmsg, 1);
+       log_msg(logmsg, LOG_DEBUG | LOG_CONS);
 
        if (ENABLED_OPT(NORMALVERBOSE))
                printf("sntp on_wire: Received no useable packet from %s!\n", addr_buf);
index ff9afa13e79468efe8f132c8bf13bd90b5c626d2..d1d9888704f87d001d7db0b7ef97617ba59032bd 100644 (file)
@@ -49,7 +49,7 @@ resolve_hosts (
 #ifdef DEBUG
                        printf("%s\n", logmsg);
 #endif
-                       log_msg(logmsg, 1);
+                       log_msg(logmsg, LOG_DEBUG | LOG_CONS);
                        free(logmsg);
                } else {
 #ifdef DEBUG