[Git][NTPsec/ntpsec][master] Implement hashprefix switch in mysyslog.c to improve capture logging.

Eric S. Raymond gitlab at mg.gitlab.com
Tue Dec 8 13:23:28 UTC 2015


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
b5667df6 by Eric S. Raymond at 2015-12-08T08:22:43Z
Implement hashprefix switch in mysyslog.c to improve capture logging.

- - - - -


3 changed files:

- include/ntp_syslog.h
- libntp/msyslog.c
- ntpd/ntp_intercept.c


Changes:

=====================================
include/ntp_syslog.h
=====================================
--- a/include/ntp_syslog.h
+++ b/include/ntp_syslog.h
@@ -12,6 +12,7 @@
 
 extern bool	syslogit;	/* log to syslogit */
 extern bool	termlogit;	/* duplicate to stdout/err */
+extern bool	hashprefix;	/* prefix with comment leader */
 extern bool	termlogit_pid;
 extern bool	msyslog_include_timestamp;
 extern FILE *	syslog_file;	/* if syslogit is false, log to


=====================================
libntp/msyslog.c
=====================================
--- a/libntp/msyslog.c
+++ b/libntp/msyslog.c
@@ -24,6 +24,7 @@
 
 bool	syslogit = true;	/* log messages to syslog */
 bool	termlogit = false;	/* duplicate to stdout/err */
+bool	hashprefix = false;	/* prefix with hash, for repolay use */
 bool	termlogit_pid = true;
 bool	msyslog_include_timestamp = true;
 FILE *	syslog_file;
@@ -176,6 +177,8 @@ addto_syslog(
 		term_file = (level <= LOG_ERR)
 				? stderr
 				: stdout;
+		if (hashprefix)
+			fputc('#', term_file);
 		if (msyslog_include_timestamp)
 			fprintf(term_file, "%s ", human_time);
 		if (termlogit_pid)


=====================================
ntpd/ntp_intercept.c
=====================================
--- a/ntpd/ntp_intercept.c
+++ b/ntpd/ntp_intercept.c
@@ -110,8 +110,14 @@ intercept_mode intercept_get_mode(void)
 void intercept_set_mode(intercept_mode newmode)
 {
     mode = newmode;
-    if (newmode == replay)
-	termlogit = syslogit = false;
+    if (mode != none) {
+	if (mode == replay)
+	    fputs("# Setting replay mode\n", stdout);
+	else if (mode == capture)
+	    fputs("# Setting capture mode\n", stdout);
+	syslogit = false;
+	hashprefix = termlogit = true;
+    }
 }
 
 void intercept_argparse(int *argc, char ***argv)
@@ -119,9 +125,9 @@ void intercept_argparse(int *argc, char ***argv)
     int i;
     for (i = 1; i < *argc; i++)
 	if (strcmp((*argv)[i], "-y") == 0)
-	    mode = capture;
+	    intercept_set_mode(capture);
 	else if  (strcmp((*argv)[i], "-Y") == 0)
-	    mode = replay;
+	    intercept_set_mode(replay);
 
     if (mode == capture)
     {



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/b5667df692cd80f940305e2d4ee2a162104f6436
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20151208/50c58a2d/attachment.html>


More information about the vc mailing list