[Git][NTPsec/ntpsec][master] feat: log rotation header
Eric S. Raymond
gitlab at mg.gitlab.com
Sun Mar 10 19:39:22 UTC 2019
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
e784a032 by James Browning at 2019-03-10T19:35:58Z
feat: log rotation header
- - - - -
2 changed files:
- ntpclients/ntploggps.py
- ntpclients/ntplogtemp.py
Changes:
=====================================
ntpclients/ntploggps.py
=====================================
@@ -45,6 +45,17 @@ except ImportError as e:
sys.exit(1)
+class logfile_header_class(logging.handlers.TimedRotatingFileHandler):
+ 'A class to modify the file logging handler.'
+ def doRollover(self):
+ 'function to add header to new file on rotaion.'
+ if str is bytes:
+ super(logfile_header_class, self).doRollover()
+ else:
+ super().doRollover()
+ self.stream.write('# Time Device TDOP nSat\n')
+
+
def logging_setup():
"Create logging object"
logFormat = logging.Formatter('%(message)s')
@@ -54,8 +65,9 @@ def logging_setup():
# Create file handler
if args.logfile:
# log to logfile
- file = logging.handlers.TimedRotatingFileHandler(
+ file = logfile_header_class(
args.logfile[0],
+ utc=True,
when='midnight',
interval=1)
else:
=====================================
ntpclients/ntplogtemp.py
=====================================
@@ -32,6 +32,17 @@ import sys
import time
+class logfile_header_class(logging.handlers.TimedRotatingFileHandler):
+ 'A class to modify the file logging handler.'
+ def doRollover(self):
+ 'function to add header to new file on rotaion.'
+ if str is bytes:
+ super(logfile_header_class, self).doRollover()
+ else:
+ super().doRollover()
+ self.stream.write('# time, sensor, value\n')
+
+
def run_binary(cmd):
"""\
Run a binary
@@ -246,8 +257,9 @@ def logging_setup():
# Create file handler
if args.logfile:
# log to logfile
- file = logging.handlers.TimedRotatingFileHandler(
+ file = logfile_header_class(
args.logfile[0],
+ utc=True,
when='midnight',
interval=1)
else:
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/e784a032f5fa1f16dba24ff40cd4cba2dd29ef95
--
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/e784a032f5fa1f16dba24ff40cd4cba2dd29ef95
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/20190310/80119770/attachment-0001.html>
More information about the vc
mailing list