[Git][NTPsec/ntpsec][master] Fixed logging bug in ntpq
Ian Bruene
gitlab at mg.gitlab.com
Thu Jun 8 20:11:19 UTC 2017
Ian Bruene pushed to branch master at NTPsec / ntpsec
Commits:
b9984cdd by Ian Bruene at 2017-06-08T14:53:25-05:00
Fixed logging bug in ntpq
- - - - -
2 changed files:
- ntpclients/ntpq
- pylib/util.py
Changes:
=====================================
ntpclients/ntpq
=====================================
--- a/ntpclients/ntpq
+++ b/ntpclients/ntpq
@@ -163,6 +163,7 @@ class Ntpq(cmd.Cmd):
self.chosts = [] # Command-line hosts
self.peers = [] # Data from NTP peers.
self.debug = 0
+ self.logfp = sys.stderr
self.pktversion = ntp.magic.NTP_OLDVERSION + 1
self.uservars = ntp.util.OrderedDict()
self.ai_family = socket.AF_UNSPEC
@@ -296,7 +297,8 @@ usage: help [ command ]
self.wideremote,
self.showunits,
termwidth=interpreter.termwidth,
- debug=interpreter.debug)
+ debug=interpreter.debug,
+ logfp=self.logfp)
try:
maxhostlen = 0
if len(self.chosts) > 1:
@@ -1628,7 +1630,8 @@ if __name__ == '__main__':
elif switch in ("-d", "--debug"):
interpreter.debug += 1
session.debug += 1
- session.logfp = open("ntpq.log", "a", 1) # 1 => line buffered
+ 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)
=====================================
pylib/util.py
=====================================
--- a/pylib/util.py
+++ b/pylib/util.py
@@ -645,13 +645,15 @@ class PeerSummary:
"Reusable report generator for peer statistics"
def __init__(self, displaymode, pktversion, showhostnames,
- wideremote, showunits=False, termwidth=None, debug=0):
+ wideremote, showunits=False, termwidth=None,
+ debug=0, logfp=sys.stderr):
self.displaymode = displaymode # peers/apeers/opeers
self.pktversion = pktversion # interpretation of flash bits
self.showhostnames = showhostnames # If false, display numeric IPs
self.showunits = showunits # If False show old style float
self.wideremote = wideremote # show wide remote names?
self.debug = debug
+ self.logfp = logfp
self.termwidth = termwidth
# By default, the peer spreadsheet layout is designed so lines just
# fit in 80 characters. This tells us how much extra horizontal space
@@ -735,7 +737,6 @@ class PeerSummary:
saw6 = False # x.6 floats for delay and friends
have_jitter = False
clock_name = ''
- self.logfp = sys.stderr
now = time.time()
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/b9984cddb6e4a0ebc37bc7949e7b4625d780c71c
---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/b9984cddb6e4a0ebc37bc7949e7b4625d780c71c
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/20170608/c399166d/attachment.html>
More information about the vc
mailing list