[Git][NTPsec/ntpsec][master] 2 commits: Fix problems with ntpq debugging flags.

Ian Bruene gitlab at mg.gitlab.com
Wed Jun 14 22:33:36 UTC 2017


Ian Bruene pushed to branch master at NTPsec / ntpsec


Commits:
97bf7aab by Ian Bruene at 2017-06-14T17:11:48-05:00
Fix problems with ntpq debugging flags.

-d flag no longer logs to a file.
Added -l/--log-to-file argument, which takes a filename.

- - - - -
710b7018 by Ian Bruene at 2017-06-14T17:26:27-05:00
Fixed missing information and incorrect formatting in ntpq docs.

- - - - -


2 changed files:

- docs/includes/ntpq-body.txt
- ntpclients/ntpq


Changes:

=====================================
docs/includes/ntpq-body.txt
=====================================
--- a/docs/includes/ntpq-body.txt
+++ b/docs/includes/ntpq-body.txt
@@ -60,7 +60,7 @@ attempt to read interactive format commands from the standard input.
 +-6+, +--ipv6+::
   Force DNS resolution of following host names on the command line to
   the IPv6 namespace.
-+-a+, +--authentication+::
++-a+, num, +--authentication+::
   Enable authentication with the numbered key.
 +-c+ cmd, +--command+=cmd::
   The following argument is interpreted as an interactive format command
@@ -70,6 +70,8 @@ attempt to read interactive format commands from the standard input.
   Increase debugging level by 1.
 +-D+ num, +--set-debug-level+=num::
   The debug level is set to the following integer argument.
++-l+, filename, +--log-to-file+=filename""
+  Log debugging output to the specified file.
 +-h+, +--help+::
   Print a usage message summarizing options end exit.
 +-n+, +--numeric+::
@@ -78,7 +80,7 @@ attempt to read interactive format commands from the standard input.
 +-p+, +--peers+::
   Print a list of the peers known to the server as well as a summary of
   their state. This is equivalent to the +peers+ interactive command.
-+-k+, +--keyfile+::
++-k+, filename, +--keyfile+::
   Specify a keyfile. ntpq will look in this file for the key specified
   with -a.
 +-V+, +--version+::
@@ -87,7 +89,7 @@ attempt to read interactive format commands from the standard input.
   Wide mode: if the host name or IP Address doesn't fit, write the
   full name/address and indent the next line so columns line up.
   The default truncates the name or address.
-+-W+ num, +--width+=num::
++-W+, num, +--width+=num::
   Force the terminal width.  Only relevant for composition of the
   peers display.
 +-u+, +--units+::


=====================================
ntpclients/ntpq
=====================================
--- a/ntpclients/ntpq
+++ b/ntpclients/ntpq
@@ -1575,6 +1575,7 @@ USAGE: ntpq [-46dphinOV] [-c str] [-D lvl] [host ...]
                                 - may appear multiple times
    -d no  debug-level     Increase output debug message level
                                 - may appear multiple times
+   -l Str log-to-file     Logs debug messages to the provided filename
    -D Int set-debug-level Set the output debug message level
                                 - may appear multiple times
    -h no  help            Print a usage message.
@@ -1595,11 +1596,12 @@ if __name__ == '__main__':
     try:
         (options, arguments) = getopt.getopt(
             sys.argv[1:],
-            "46a:c:dD:hk:npVwW:u",
+            "46a:c:dD:hk:npVwW:ul:",
             ["ipv4", "ipv6", "authentication=",
              "command=", "debug", "set-debug-level=",
              "help", "keyfile", "numeric", "peers",
-             "version", "wide", "width=", "units"])
+             "version", "wide", "width=", "units",
+             "log-to-file"])
     except getopt.GetoptError as e:
         sys.stderr.write("%s\n" % e)
         sys.stderr.write(usage)
@@ -1611,6 +1613,7 @@ if __name__ == '__main__':
     interpreter = Ntpq(session)
 
     keyid = keyfile = None
+    logfp = sys.stderr
 
     for (switch, val) in options:
         if switch in ("-4", "--ipv4"):
@@ -1625,8 +1628,6 @@ if __name__ == '__main__':
         elif switch in ("-d", "--debug"):
             interpreter.debug += 1
             session.debug += 1
-            logfp = open("ntpq.log", "a", 1)    # 1 => line buffered
-            session.logfp = interpreter.logfp = logfp
         elif switch in ("-D", "--set-debug-level"):
             errmsg = "Error: -D parameter '%s' not a number\n"
             cast = ntp.util.safeargcast(val, int, errmsg, usage)
@@ -1651,6 +1652,12 @@ if __name__ == '__main__':
                                                          errmsg, usage)
         elif switch in ("-u", "--units"):
             interpreter.showunits = True
+        elif switch in ("-l", "--log-to-file"):
+            if logfp != sys.stderr:
+                logfp.close()
+            logfp = open(val, "a", 1)  # 1 => line buffered
+
+    session.logfp = interpreter.logfp = logfp
 
     if keyfile is not None:  # Have a -k, setup the auth
         credentials = None



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/31b148e3a9ccc016b47408f918a9cab55141b06e...710b7018518432c9f65fb0df55438eb94b5b20da

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/31b148e3a9ccc016b47408f918a9cab55141b06e...710b7018518432c9f65fb0df55438eb94b5b20da
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170614/b1af79cd/attachment.html>


More information about the vc mailing list