Skip to content

Commit

Permalink
fix: allow setting RUST_LOG manually (#56)
Browse files Browse the repository at this point in the history
* fix: allow setting RUST_LOG manually

* fixup

* fix

---------

Co-authored-by: Asmir Avdicevic <[email protected]>
  • Loading branch information
Frando and Arqu authored Jun 24, 2024
1 parent e6155a1 commit 8661a7d
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions netsim/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def logs_on_error(nodes, prefix, code=1, message=None):
if message:
print('[ERROR] Message:', message)

def run(nodes, prefix, args, debug=False, full_debug=False, visualize=False):
def run(nodes, prefix, args, debug=False, visualize=False):
integration = args.integration
topo = StarTopo(nodes=nodes)
net = Mininet(topo = topo, waitConnected=True, link=TCLink)
Expand All @@ -60,11 +60,12 @@ def run(nodes, prefix, args, debug=False, full_debug=False, visualize=False):

env_vars = os.environ.copy()
if debug:
# reduce logging, track only those of interest
# magicsock::endpoint required for iroh integration tests
env_vars['RUST_LOG'] = 'error,iroh_net::magicsock::node_map::endpoint=trace'
if full_debug:
env_vars['RUST_LOG'] = 'debug'
env_vars['RUST_LOG'] = 'debug'
if not 'RUST_LOG' in env_vars:
env_vars['RUST_LOG'] = 'warn'
# magicsock::endpoint required for iroh integration tests
env_vars['RUST_LOG'] += ",iroh_net::magicsock::node_map::endpoint=trace"


p_box = []
p_short_box = []
Expand Down Expand Up @@ -204,8 +205,6 @@ def cleanup_tmp_dirs(temp_dirs):
else:
paths.append(args.cfg)

full_debug = args.debug

for path in paths:
config_f = open(path, 'r')
config = json.load(config_f)
Expand All @@ -224,7 +223,7 @@ def cleanup_tmp_dirs(temp_dirs):
# viz = case['visualize']
print('running "%s"...' % prefix)
if not args.r:
run(nodes, prefix, args, True, full_debug, viz)
run(nodes, prefix, args, args.debug, viz)
stats_parser(nodes, prefix)
integration_parser(nodes, prefix)
if viz:
Expand All @@ -234,4 +233,4 @@ def cleanup_tmp_dirs(temp_dirs):
'topo': 'logs/' + prefix + '.topo.json',
'output': 'viz/' + prefix + '.svg'
}
run_viz(viz_args)
run_viz(viz_args)

0 comments on commit 8661a7d

Please sign in to comment.