summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <ikj1234i@yahoo.com>2020-08-06 20:43:00 -0400
committerMax <ikj1234i@yahoo.com>2020-08-06 20:43:00 -0400
commit856ed974198212571453a09d4317d2781d21717a (patch)
tree6ac19ec1f7e1059f7bdc953ea00d0cb159024dbf
parenta6bd25163a28f23bafb36673c13042d054ecf4c9 (diff)
add log_ts.pyHEADmaster
-rwxr-xr-xop25/gr-op25_repeater/apps/log_ts.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/op25/gr-op25_repeater/apps/log_ts.py b/op25/gr-op25_repeater/apps/log_ts.py
new file mode 100755
index 0000000..5306d49
--- /dev/null
+++ b/op25/gr-op25_repeater/apps/log_ts.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+
+# Copyright 2020 Graham Norbury
+#
+# This file is part of OP25
+#
+# OP25 is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# OP25 is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+# License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with OP25; see the file COPYING. If not, write to the Free
+# Software Foundation, Inc., 51 Franklin Street, Boston, MA
+# 02110-1301, USA.
+
+# Modify TS_FORMAT to control logger timestamp format
+# 0 = legacy epoch seconds
+# 1 = formatted mm/dd/yy hh:mm:ss.usec
+TS_FORMAT = 1
+
+import time
+class log_ts(object):
+ @staticmethod
+ def get(supplied_ts=None):
+ if supplied_ts is None:
+ ts = time.time()
+ else:
+ ts = supplied_ts
+
+ if TS_FORMAT == 0:
+ formatted_ts = "{:.6f}".format(ts)
+ else:
+ formatted_ts = "{:s}{:s}".format(time.strftime("%m/%d/%y %H:%M:%S",time.localtime(ts)),"{:.6f}".format(ts - int(ts)).lstrip("0"))
+
+ return formatted_ts
+