summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2024-02-23 17:55:40 +0000
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>2024-02-24 08:47:51 +0000
commitbd1390eb49245caf184004a42dc236bd92923b72 (patch)
tree5f82b065294570695ada9eba330de317667cee9c
parent97590dcad287107e44fbe336e1c85a000cc2900f (diff)
cerbero: add --clocktime argument to print absolute time as well
Part-of: <https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/1381>
-rw-r--r--cerbero/main.py8
-rw-r--r--cerbero/utils/messages.py8
2 files changed, 16 insertions, 0 deletions
diff --git a/cerbero/main.py b/cerbero/main.py
index d72151d4..f96d7162 100644
--- a/cerbero/main.py
+++ b/cerbero/main.py
@@ -71,6 +71,8 @@ class Main(object):
"""Initialize logging"""
if self.args.timestamps:
m.START_TIME = time.monotonic()
+ if self.args.clocktime:
+ m.PRINT_CLOCK_TIME = True
logging.getLogger().setLevel(logging.INFO)
logging.getLogger().addHandler(logging.StreamHandler())
@@ -93,6 +95,12 @@ class Main(object):
help=_('Print timestamps with every message printed'),
)
self.parser.add_argument(
+ '--clocktime',
+ action='store_true',
+ default=False,
+ help=_('Print absolute clock times with every message printed'),
+ )
+ self.parser.add_argument(
'--list-variants', action='store_true', default=False, help=_('List available variants')
)
self.parser.add_argument(
diff --git a/cerbero/utils/messages.py b/cerbero/utils/messages.py
index 45d863fc..5b825d22 100644
--- a/cerbero/utils/messages.py
+++ b/cerbero/utils/messages.py
@@ -36,6 +36,7 @@ STEP_TPL = '[(%s/%s @ %d%%) %s -> %s]'
START_TIME = None
SHELL_CLEAR_LINE = '\r\033[K'
SHELL_MOVE_UP = '\033[F'
+PRINT_CLOCK_TIME = False
# Enable support fot VT-100 escapes in Windows 10
@@ -98,9 +99,16 @@ STDOUT = StdoutManager()
def prepend_time(end=' '):
+ global PRINT_CLOCK_TIME
global START_TIME
s = ''
+ if PRINT_CLOCK_TIME:
+ s += str(datetime.datetime.now().strftime('%H:%M:%S'))
+ if START_TIME is None:
+ s += end
if START_TIME is not None:
+ if PRINT_CLOCK_TIME:
+ s += ' | '
s += str(datetime.timedelta(microseconds=int((time.monotonic() - START_TIME) * 1e6)))
s += end
return s