Skip to content

Commit 30cecc3

Browse files
committed
feat: Add detailed logging to pyshell function when debug environment variable is set
1 parent 3adcb42 commit 30cecc3

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

easymotion.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ def get_string_width(s):
1616
return width
1717

1818
def pyshell(cmd):
19-
# Add logging
20-
with open(os.path.expanduser('~/easymotion.log'), 'a') as log:
21-
log.write(f"{cmd}\n")
22-
result = os.popen(cmd).read()
23-
log.write(f"Result: {result}\n")
24-
log.write("-" * 40 + "\n")
25-
return result
19+
debug = os.environ.get('TMUX_EASYMOTION_DEBUG') == 'true'
20+
if debug:
21+
with open(os.path.expanduser('~/easymotion.log'), 'a') as log:
22+
log.write(f"Command: {cmd}\n")
23+
result = os.popen(cmd).read()
24+
log.write(f"Result: {result}\n")
25+
log.write("-" * 40 + "\n")
26+
return result
27+
return os.popen(cmd).read()
2628

2729
def tmux_pane_id():
2830
# Get the ID of the pane that launched this script

0 commit comments

Comments
 (0)