Skip to content

Commit b3e75d1

Browse files
committed
tmux_cmd(fix[logging]): guard pre-execution log with isEnabledFor
why: shlex.join(cmd) was computed unconditionally outside the isEnabledFor guard, wasting cycles when DEBUG is disabled. what: - Move cmd_str = shlex.join(cmd) inside the if logger.isEnabledFor block - Matches the post-execution logging pattern at line 307
1 parent 9d8ec2e commit b3e75d1

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

src/libtmux/common.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,12 +260,13 @@ def __init__(self, *args: t.Any, tmux_bin: str | None = None) -> None:
260260

261261
self.cmd = cmd
262262

263-
cmd_str = shlex.join(cmd)
264-
logger.debug(
265-
"running %s",
266-
cmd_str,
267-
extra={"tmux_cmd": cmd_str},
268-
)
263+
if logger.isEnabledFor(logging.DEBUG):
264+
cmd_str = shlex.join(cmd)
265+
logger.debug(
266+
"running %s",
267+
cmd_str,
268+
extra={"tmux_cmd": cmd_str},
269+
)
269270

270271
try:
271272
self.process = subprocess.Popen(

0 commit comments

Comments
 (0)