traffic: improve debug messages in traffic_replay
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Fri, 19 Oct 2018 03:26:19 +0000 (16:26 +1300)
committerDouglas Bagnall <dbagnall@samba.org>
Tue, 8 Jan 2019 22:55:34 +0000 (23:55 +0100)
tracebacks and less nonsense at higher debug levels.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
script/traffic_replay

index f1e8372c8bbdfa256aee158aede2802359127157..6131ffad2e8d1efc4daee2b1d845f8079f2b5ed0 100755 (executable)
@@ -234,6 +234,9 @@ def main():
             open(opts.traffic_summary, 'w').close()
         except IOError:
             # exception info will be added to log automatically
+            if debuglevel > 0:
+                import traceback
+                traceback.print_exc()
             logger.exception(("the supplied traffic summary destination "
                               "(%s) is not writable" % opts.traffic_summary))
             sys.exit()
@@ -258,6 +261,9 @@ def main():
                                                                   opts.duration,
                                                                   opts.replay_rate)
         except ValueError:
+            if debuglevel > 0:
+                import traceback
+                traceback.print_exc()
             logger.error(("Could not parse %s, which does not seem to be "
                           "a model generated by script/traffic_learner."
                           % model_file))
@@ -266,13 +272,6 @@ def main():
     else:
         conversations = []
 
-    if debuglevel > 5:
-        for c in traffic.seq_to_conversations(conversations):
-            for p in c.packets:
-                print("    ", p, file=sys.stderr)
-
-        print('=' * 72, file=sys.stderr)
-
     if opts.number_of_users and opts.number_of_users < len(conversations):
         logger.error(("--number-of-users (%d) is less than the "
                       "number of conversations to replay (%d)"