Skip to content

Commit a3244e3

Browse files
committed
libtmux(fix[logging]): use dynamic messages for all_except kill paths
why: kill(all_except=True) kills *other* objects, not the calling object. The log message should reflect which action was taken. what: - Session.kill(): "other sessions killed" when all_except=True - Window.kill(): "other windows killed" when all_except=True - Pane.kill(): "other panes killed" when all_except=True
1 parent c89d264 commit a3244e3

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/libtmux/pane.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,8 @@ def kill(
573573
if self.pane_id is not None:
574574
extra["tmux_pane"] = str(self.pane_id)
575575
extra["tmux_target"] = str(self.pane_id)
576-
logger.info("pane killed", extra=extra)
576+
msg = "other panes killed" if all_except else "pane killed"
577+
logger.info(msg, extra=extra)
577578

578579
"""
579580
Commands ("climber"-helpers)

src/libtmux/session.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,14 +395,15 @@ def kill(
395395
if proc.stderr:
396396
raise exc.LibTmuxException(proc.stderr)
397397

398+
msg = "other sessions killed" if all_except else "session killed"
398399
extra: dict[str, str] = {
399400
"tmux_subcommand": "kill-session",
400401
}
401402
if self.session_name is not None:
402403
extra["tmux_session"] = str(self.session_name)
403404
if self.session_id is not None:
404405
extra["tmux_target"] = str(self.session_id)
405-
logger.info("session killed", extra=extra)
406+
logger.info(msg, extra=extra)
406407

407408
def switch_client(self) -> Session:
408409
"""Switch client to session.

src/libtmux/window.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ def kill(
552552
if proc.stderr:
553553
raise exc.LibTmuxException(proc.stderr)
554554

555-
msg = "windows killed" if all_except else "window killed"
555+
msg = "other windows killed" if all_except else "window killed"
556556
extra: dict[str, str] = {
557557
"tmux_subcommand": "kill-window",
558558
}

0 commit comments

Comments
 (0)