Skip to content

Commit 08d4f79

Browse files
committed
libtmux(fix[logging]): move cmd_str inside isEnabledFor guard
why: shlex.join() was computed on every fetch_objs call regardless of log level. Per AGENTS.md, expensive computations for log extra values should be guarded with isEnabledFor. what: - Move cmd_str = shlex.join(...) inside first isEnabledFor(DEBUG) block - Lazily compute in second block if DEBUG was enabled between the two
1 parent 1cc1adf commit 08d4f79

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/libtmux/neo.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,10 @@ 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])
309+
cmd_str: str | None = None
310310

311311
if logger.isEnabledFor(logging.DEBUG):
312+
cmd_str = shlex.join([str(x) for x in tmux_cmds])
312313
logger.debug(
313314
"tmux list queried",
314315
extra={
@@ -325,6 +326,8 @@ def fetch_objs(
325326
outputs = [parse_output(line) for line in proc.stdout]
326327

327328
if logger.isEnabledFor(logging.DEBUG):
329+
if cmd_str is None:
330+
cmd_str = shlex.join([str(x) for x in tmux_cmds])
328331
logger.debug(
329332
"tmux list parsed",
330333
extra={

0 commit comments

Comments
 (0)