tmux-plugins / tmux-logging

Easy logging and screen capturing for Tmux.
MIT License
1.03k stars 113 forks source link

How to start logging using command line.. #58

Closed rameshsanth closed 3 years ago

rameshsanth commented 3 years ago

I have a tmux script that creates a new window, runs bunch of CLI's I want to log all the console output in a custom log file.

I modified toggle_logging.sh to accept a session name as an argument. It was a fairly simple bash change (attached below) I succeeded in turning on logging using below CLI.. send "tmux run-shell ~/.tmux/plugins/tmux-logging/scripts/toggle_logging.sh" ENTER \;

However, the above CLI doesn't accept any arguments. Hence i couldn't create a custom log file. I tried doing this but no logging is happening.

         send source\ ~/.tmux/plugins/tmux-logging/scripts/toggle_logging.sh ENTER\; \
         send start_pipe_pane\ sim_run_logfile ENTER \; \

Here is the script change i did to pass a filename arg

diff --git a/scripts/toggle_logging.sh b/scripts/toggle_logging.sh
index e240d8c..455a299 100755
--- a/scripts/toggle_logging.sh
+++ b/scripts/toggle_logging.sh
@@ -7,9 +7,10 @@ source "$CURRENT_DIR/shared.sh"

 start_pipe_pane() {
-       local file=$(expand_tmux_format_path "${logging_full_filename}")
+       local fname=$(expand_tmux_format_path "${logging_full_filename}")
+       local file=${1:-$fname}
        "$CURRENT_DIR/start_logging.sh" "${file}"
-       display_message "Started logging to ${logging_full_filename}"
+       display_message "Started logging to ${file}"
 }

 stop_pipe_pane() {
@@ -47,13 +48,14 @@ toggle_pipe_pane() {
                stop_pipe_pane
        else
                set_logging_variable "logging"
-               start_pipe_pane
+        echo starting pipe
+               start_pipe_pane $1
        fi
 }

 main() {
        if supported_tmux_version_ok; then
-               toggle_pipe_pane
+               toggle_pipe_pane $1
        fi
 }
-main
+main $1
rameshsanth commented 3 years ago

The script worked.. the file was created in my home directory, not current directory.. I didn't look for the log file in correct place