You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ch...@apache.org on 2020/05/13 18:26:10 UTC

[qpid-dispatch] 02/02: [NO-JIRA] Scraper - add timestamp switch to sequence diagram generator

This is an automated email from the ASF dual-hosted git repository.

chug pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git

commit 04e69505d54b0c14ea7950c070c1af185df07b7d
Author: Chuck Rolke <ch...@apache.org>
AuthorDate: Wed May 13 14:25:06 2020 -0400

    [NO-JIRA] Scraper - add timestamp switch to sequence diagram generator
---
 tools/scraper/seq-diag-gen.py | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/tools/scraper/seq-diag-gen.py b/tools/scraper/seq-diag-gen.py
index 7313f8e..1c7f8f4 100755
--- a/tools/scraper/seq-diag-gen.py
+++ b/tools/scraper/seq-diag-gen.py
@@ -46,6 +46,7 @@ class log_record:
         # print("DEBUG input line: ", index, line)
         dateandtime, name_left, direction, name_right, perf, router_line = line.split('|')
         self.dateandtime = dateandtime.strip()
+        self.time = self.dateandtime.split(' ')[1]
         self.index = index
         self.name_left = name_left.strip()
         self.direction = direction.strip()
@@ -77,25 +78,31 @@ class log_record:
         peer_rec.peer_log_rec = self
         return True
 
-    def show_for_sdorg(self):
+    def show_for_sdorg(self, showtime):
         # A single sd.org vector consumes one or two log lines.
         #  One if from an external actor.
         #  Two if a message goes between routers.
         # Leave space where the message is supposed to land in the receiving routers
         if self.peer_log_rec is None:
-            print("%s->%s:%s" % (self.sentby, self.rcvdby, self.performative))
+            if showtime:
+                print("%s->%s:%s %s" % (self.sentby, self.rcvdby, self.time, self.performative))
+            else:
+                print("%s->%s:%s" % (self.sentby, self.rcvdby, self.performative))
         else:
             if self.peer_log_rec.index > self.index:
                 linediff = int(self.peer_log_rec.index) - int(self.index)
                 space = -MAGIC_SPACE_NUMBER * (linediff - 1)
-                print("%s->(%s)%s:%s" %(self.sentby, str(linediff), self.rcvdby, self.performative))
+                if showtime:
+                    print("%s->(%s)%s:%s %s" %(self.sentby, str(linediff), self.rcvdby, self.time, self.performative))
+                else:
+                    print("%s->(%s)%s:%s" % (self.sentby, str(linediff), self.rcvdby, self.performative))
                 print("space %s" % (str(space)))
             else:
                 print("space %d" % MAGIC_SPACE_NUMBER)
 
     def diag_dump(self):
-        cmn = ("index: %d, sentby: %s, rcvdby: %s, performative: %s, router_line: %s" %
-               (self.index, self.sentby, self.rcvdby, self.performative, self.router_line))
+        cmn = ("index: %d, dateandtime: %s, sentby: %s, rcvdby: %s, performative: %s, router_line: %s" %
+               (self.dateandtime, self.index, self.sentby, self.rcvdby, self.performative, self.router_line))
         if self.peer_log_rec is None:
             print(cmn)
         else:
@@ -134,6 +141,9 @@ if __name__ == "__main__":
     parser = optparse.OptionParser(usage="%prog [options]",
                                    description="cooks a scraper log snippet into sequencediagram.org source")
     parser.add_option("-f", "--filename", action="append", help="logfile to use or - for stdin")
+    parser.add_option('--timestamp', '-t',
+                      action='store_true',
+                      help='Include HH:MM:SS.ssssss in output')
 
     (opts, args) = parser.parse_args()
     if not opts.filename:
@@ -153,7 +163,7 @@ if __name__ == "__main__":
 
             # process the list of records
             for log_rec in log_recs:
-                log_rec.show_for_sdorg()
+                log_rec.show_for_sdorg(opts.timestamp)
 
             # diag dump
             #print("\nDiag dump")


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org