Skip to content

Commit 5712175

Browse files
committed
vtd: Add logging option to startup script
1 parent db31c21 commit 5712175

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

plugins/vtd/bin/vtd-launch

+13-2
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,20 @@ import libtmux
4444
required=True,
4545
help="The tmux session name to use.",
4646
)
47+
@click.option(
48+
"-l",
49+
"--logfile",
50+
type=click.Path(file_okay=True, dir_okay=False),
51+
help="VTD logfile path.",
52+
)
4753
@click.pass_context
4854
def main(
4955
ctx,
5056
verbose: int,
5157
vtd_root: str,
5258
runtime_dir: str,
5359
tmux_session: str,
60+
logfile: str,
5461
):
5562
"""Start and stop a VTD simulation."""
5663

@@ -63,11 +70,12 @@ def main(
6370
logging.basicConfig(format="%(message)s", stream=sys.stderr, level=level)
6471

6572
class Options:
66-
def __init__(self, root: str, runtime: str, session_name: str):
73+
def __init__(self, root: str, runtime: str, session_name: str, log_file: str):
6774
self.root_dir = Path(root)
6875
self.runtime_dir = Path(runtime)
6976
self.tmux = libtmux.Server()
7077
self.session_name = session_name
78+
self.log_file = log_file
7179

7280
def get_session(self) -> Optional[libtmux.Session]:
7381
return self.tmux.find_where({"session_name": self.session_name})
@@ -78,7 +86,7 @@ def main(
7886
def new_session(self) -> libtmux.Session:
7987
return self.tmux.new_session(self.session_name)
8088

81-
ctx.obj = Options(vtd_root, runtime_dir, tmux_session)
89+
ctx.obj = Options(vtd_root, runtime_dir, tmux_session, logfile)
8290

8391

8492
# _________________________________________________________________________
@@ -247,6 +255,9 @@ def start(
247255
pane = window.attached_pane
248256
pane.clear()
249257

258+
if opt.log_file:
259+
log_file = shlex.quote(str(opt.log_file))
260+
pane.cmd("pipe", f"cat >> {log_file}")
250261
runtime_dir = shlex.quote(str(opt.runtime_dir))
251262
pane.send_keys(f"cd {runtime_dir}")
252263
pane.send_keys(f"export VTD_ROOT={runtime_dir}")

tests/bootstrap_vtd.json

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
{
1313
"path": "${VTD_LAUNCH}",
1414
"args": [
15+
"-l", "/tmp/vtd.log",
1516
"start",
1617
"--vtd-setup", "${THIS_STACKFILE_DIR}/../plugins/vtd/contrib/setups/Cloe.noGUInoIG",
1718
"--vtd-project", "${THIS_STACKFILE_DIR}/../plugins/vtd/contrib/projects/cloe_tests"

0 commit comments

Comments
 (0)