[Git][NTPsec/ntpsec][master] Set up logging for Python ntpdig properly.

Eric S. Raymond gitlab at mg.gitlab.com
Wed Nov 23 16:55:31 UTC 2016


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


Commits:
880d14a7 by Eric S. Raymond at 2016-11-23T11:54:54-05:00
Set up logging for Python ntpdig properly.

- - - - -


2 changed files:

- libntp/pymodule.c
- ntpdig/pyntpdig


Changes:

=====================================
libntp/pymodule.c
=====================================
--- a/libntp/pymodule.c
+++ b/libntp/pymodule.c
@@ -14,6 +14,7 @@
 #include "ntp_fp.h"
 #include "ntp_stdlib.h"
 #include "ntp_random.h"
+#include "ntp_syslog.h"
 #include "timespecops.h"
 
 #include "ntp_config.h"
@@ -39,6 +40,19 @@ ntpc_setprogname(PyObject *self, PyObject *args)
     if (!PyArg_ParseTuple(args, "s", &s))
 	return NULL;
     progname = strdup(s);
+
+    /*
+     * This function is only called from clients.  Therefore
+     * log to stderr rather than syslog, and suppress logfile
+     * impedimenta.  If we ever want finer-grained control, that
+     * will be easily implemented with additional arguments.
+     */
+    syslogit = false;	/* don't log messages to syslog */
+    termlogit = true;	/* duplicate to stdout/err */
+    hashprefix = false;	/* prefix with hash, for replay use */
+    termlogit_pid = false;
+    msyslog_include_timestamp = false;
+
     Py_RETURN_NONE;
 }
 


=====================================
ntpdig/pyntpdig
=====================================
--- a/ntpdig/pyntpdig
+++ b/ntpdig/pyntpdig
@@ -344,6 +344,7 @@ if __name__ == '__main__':
 	# If we can step or slew and and |offset| > steplimit, then step.
         rc = True
         offset = syncpacket.adjust()
+        ntp.ntpc.setprogname("ntpdig")
         if step and (not slew or (slew and (abs(offset) > steplimit))):
 		rc = ntp.ntpc.step_systime(offset)
 	elif slew:



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/880d14a74f5d21ce9f7af700ee4cc57b760254d0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161123/750941f9/attachment.html>


More information about the vc mailing list