Skip to content

Commit b55be19

Browse files
committed
libtmux(fix[logging]): add tmux_stderr_len, hoist shlex.join, fix message tense
why: Three low-consensus but valid logging conformance findings. what: - common.py: add tmux_stderr_len to DEBUG extra dict for symmetry with tmux_stdout_len - neo.py: hoist shlex.join to a local variable before first guard, reuse in both log calls - pytest_plugin.py: move log after kill_session and change message to past tense "old test session killed"
1 parent 8b1f488 commit b55be19

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/libtmux/common.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ def __init__(self, *args: t.Any) -> None:
302302
"tmux_stdout": self.stdout[:100],
303303
"tmux_stderr": self.stderr[:100],
304304
"tmux_stdout_len": len(self.stdout),
305+
"tmux_stderr_len": len(self.stderr),
305306
},
306307
)
307308

src/libtmux/neo.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,12 +306,14 @@ def fetch_objs(
306306

307307
tmux_cmds.append(f"-F{format_string}")
308308

309+
cmd_str = shlex.join([str(x) for x in tmux_cmds])
310+
309311
if logger.isEnabledFor(logging.DEBUG):
310312
logger.debug(
311313
"tmux list queried",
312314
extra={
313315
"tmux_subcommand": list_cmd,
314-
"tmux_cmd": shlex.join([str(x) for x in tmux_cmds]),
316+
"tmux_cmd": cmd_str,
315317
},
316318
)
317319

@@ -327,7 +329,7 @@ def fetch_objs(
327329
"tmux list parsed",
328330
extra={
329331
"tmux_subcommand": list_cmd,
330-
"tmux_cmd": shlex.join([str(x) for x in tmux_cmds]),
332+
"tmux_cmd": cmd_str,
331333
"tmux_stdout_len": len(proc.stdout),
332334
},
333335
)

src/libtmux/pytest_plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,14 +251,14 @@ def session(
251251
server.switch_client(target_session=session_id)
252252

253253
for old_test_session in old_test_sessions:
254+
server.kill_session(old_test_session)
254255
logger.debug(
255-
"old test session found, killing",
256+
"old test session killed",
256257
extra={
257258
"tmux_session": old_test_session,
258259
"tmux_subcommand": "kill-session",
259260
},
260261
)
261-
server.kill_session(old_test_session)
262262
assert session.session_name == TEST_SESSION_NAME
263263
assert TEST_SESSION_NAME != "tmuxp"
264264

0 commit comments

Comments
 (0)