---
* [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
#ifdef DEBUG
debug_msg(msg);
#endif
- log_msg(msg, 2);
+ log_msg(msg, LOG_WARNING | LOG_CONS);
return;
}
debug_msg(msg);
printf("%s\n", msg);
#endif
- log_msg(msg, 2);
+ log_msg(msg, LOG_WARNING | LOG_CONS);
return;
}
debug_msg(msg);
printf("%s\n", msg);
#endif
- log_msg(msg, 1);
+ log_msg(msg, LOG_DEBUG | LOG_CONS);
}
fclose(db_s);
return;
#ifdef DEBUG
debug_msg(msg);
#endif
- log_msg(msg, 2);
+ log_msg(msg, LOG_WARNING | LOG_CONS);
fclose(db_s);
return;
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);
}
}
#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);
ai_fam_pref = AF_INET6;
}
- log_msg("Started sntp", 0);
-
optct = optionProcess(&sntpOptions, argc, argv);
argc -= optct;
argv += optct;
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
"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;
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);
#ifdef DEBUG
printf("%s\n", logmsg);
#endif
- log_msg(logmsg, 1);
+ log_msg(logmsg, LOG_DEBUG | LOG_CONS);
free(logmsg);
} else {
#ifdef DEBUG