[Git][NTPsec/ntpsec][master] 2 commits: msyslog_term -> termlogit, msyslog_term_pid -> termlogit_pid.
Eric S. Raymond
gitlab at mg.gitlab.com
Tue Nov 24 18:23:28 UTC 2015
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
2597e4a8 by Eric S. Raymond at 2015-11-24T13:22:41Z
msyslog_term -> termlogit, msyslog_term_pid -> termlogit_pid.
No logic changes. The point of this commit is to make the next one, which will
change the way logging is controlled, easier to read.
- - - - -
92ecea22 by Eric S. Raymond at 2015-11-24T13:22:41Z
This enable us to make three minor functional changes:
(1) waf check -v no longer spams log messages to stdout (Gitlab issue #19).
(2) ntpdig now suppresses logging to stdout (long-time to-do from Hal Murray).
(3) The (not yet working) TESTFRAME modes wuill fully suppress logging.
- - - - -
10 changed files:
- include/ntp_syslog.h
- libntp/emalloc.c
- libntp/intercept.c
- libntp/msyslog.c
- ntpd/ntp_proto.c
- ntpd/ntpd.c
- ntpd/ntpsim.c
- ntpdig/log.c
- ntpdig/main.c
- tests/common/tests_main.c
Changes:
=====================================
include/ntp_syslog.h
=====================================
--- a/include/ntp_syslog.h
+++ b/include/ntp_syslog.h
@@ -10,9 +10,9 @@
#include "ntp_types.h" /* uint32_t type */
-extern bool syslogit;
-extern bool msyslog_term; /* duplicate to stdout/err */
-extern bool msyslog_term_pid;
+extern bool syslogit; /* log to syslogit */
+extern bool termlogit; /* duplicate to stdout/err */
+extern bool termlogit_pid;
extern bool msyslog_include_timestamp;
extern FILE * syslog_file; /* if syslogit is false, log to
this file and not syslog */
=====================================
libntp/emalloc.c
=====================================
--- a/libntp/emalloc.c
+++ b/libntp/emalloc.c
@@ -42,7 +42,7 @@ ereallocz(
mem = EREALLOC_IMPL(ptr, allocsz, file, line);
if (NULL == mem) {
- msyslog_term = true;
+ termlogit = true;
#ifndef EREALLOC_CALLSITE
msyslog(LOG_ERR, "fatal out of memory (%lu bytes)",
(u_long)newsz);
=====================================
libntp/intercept.c
=====================================
--- a/libntp/intercept.c
+++ b/libntp/intercept.c
@@ -110,7 +110,7 @@ void intercept_set_mode(intercept_mode newmode)
{
mode = newmode;
if (newmode == replay)
- syslogit = false;
+ termlogit = syslogit = false;
}
void intercept_argparse(int *argc, char ***argv)
=====================================
libntp/msyslog.c
=====================================
--- a/libntp/msyslog.c
+++ b/libntp/msyslog.c
@@ -22,9 +22,9 @@
#endif
-bool syslogit = true;
-bool msyslog_term = false; /* duplicate to stdout/err */
-bool msyslog_term_pid = true;
+bool syslogit = true; /* log messages to syslog */
+bool termlogit = false; /* duplicate to stdout/err */
+bool termlogit_pid = true;
bool msyslog_include_timestamp = true;
FILE * syslog_file;
char * syslog_fname;
@@ -142,15 +142,13 @@ addto_syslog(
prog = progname;
}
- log_to_term = msyslog_term;
+ log_to_term = termlogit;
log_to_file = false;
if (syslogit)
syslog(level, "%s", msg);
else
if (syslog_file != NULL)
log_to_file = true;
- else
- log_to_term = true;
#if DEBUG
if (debug > 0)
log_to_term = true;
@@ -163,7 +161,7 @@ addto_syslog(
human_time = humanlogtime();
else /* suppress gcc pot. uninit. warning */
human_time = NULL;
- if (msyslog_term_pid || log_to_file)
+ if (termlogit_pid || log_to_file)
pid = getpid();
else /* suppress gcc pot. uninit. warning */
pid = -1;
@@ -180,7 +178,7 @@ addto_syslog(
: stdout;
if (msyslog_include_timestamp)
fprintf(term_file, "%s ", human_time);
- if (msyslog_term_pid)
+ if (termlogit_pid)
fprintf(term_file, "%s[%d]: ", prog, pid);
fprintf(term_file, "%s%s", msg, nl_or_empty);
fflush(term_file);
=====================================
ntpd/ntp_proto.c
=====================================
--- a/ntpd/ntp_proto.c
+++ b/ntpd/ntp_proto.c
@@ -355,7 +355,7 @@ transmit(
if (peer_ntpdate == 0) {
msyslog(LOG_NOTICE,
"ntpd: no servers found");
- if (!msyslog_term)
+ if (!termlogit)
printf(
"ntpd: no servers found\n");
exit (0);
=====================================
ntpd/ntpd.c
=====================================
--- a/ntpd/ntpd.c
+++ b/ntpd/ntpd.c
@@ -580,10 +580,11 @@ ntpdmain(
/* honor -l/--logfile option to log to a file */
if (logfilename != NULL) {
syslogit = false;
+ termlogit = false;
change_logfile(logfilename, false);
} else {
if (nofork)
- msyslog_term = true;
+ termlogit = true;
if (saveconfigquit || dumpopts)
syslogit = false;
}
@@ -618,7 +619,7 @@ ntpdmain(
uid = getuid();
if (uid && !saveconfigquit && !dumpopts) {
- msyslog_term = true;
+ termlogit = true;
msyslog(LOG_ERR,
"must be run as root, not uid %ld", (long)uid);
exit(1);
=====================================
ntpd/ntpsim.c
=====================================
--- a/ntpd/ntpsim.c
+++ b/ntpd/ntpsim.c
@@ -120,7 +120,7 @@ ntpsim(
/* Initialize ntp modules */
initializing = true;
- msyslog_term = true;
+ termlogit = true;
init_sim_io();
init_auth();
init_util();
=====================================
ntpdig/log.c
=====================================
--- a/ntpdig/log.c
+++ b/ntpdig/log.c
@@ -11,9 +11,9 @@ ntpdig_init_logging(
const char *prog
)
{
- msyslog_term = true;
+ termlogit = false;
init_logging(prog, 0, false);
- msyslog_term_pid = false;
+ termlogit_pid = false;
msyslog_include_timestamp = false;
}
=====================================
ntpdig/main.c
=====================================
--- a/ntpdig/main.c
+++ b/ntpdig/main.c
@@ -1375,12 +1375,17 @@ handle_pkt(
leaptxt,
time_adjusted ? "true" : "false");
}
- else
- msyslog(LOG_INFO, "%s %+.*f%s %s s%d %s%s", ts_str,
+ else {
+ char msgbuf[132];
+ snprintf(msgbuf, sizeof(msgbuf),
+ "%s %+.*f%s %s s%d %s%s", ts_str,
digits, offset, disptxt,
hostnameaddr(hostname, host), stratum,
leaptxt,
time_adjusted ? " [excess]" : "");
+ printf("%s\n", msgbuf);
+ msyslog(LOG_INFO, "%s", msgbuf);
+ }
free(ts_str);
if (p_NTPDIG_PRETEND_TIME)
=====================================
tests/common/tests_main.c
=====================================
--- a/tests/common/tests_main.c
+++ b/tests/common/tests_main.c
@@ -25,6 +25,7 @@ const char* tests_main_args(int arg)
static void RunAllTests(void)
{
syslogit = false;
+ termlogit = false;
#ifdef TEST_NTPDIG
RUN_TEST_GROUP(crypto);
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/425d2481f803e5e5ba6a3ca0fe1555b83ec2bd91...92ecea22056735e1b962793368966e2286249f3b
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20151124/7aea40a2/attachment.html>
More information about the vc
mailing list