aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2023-08-19 10:08:05 +0200
committerMichael Albinus2023-08-19 10:08:05 +0200
commitfedaf25bb3b36e8bb85ba72a69e06117842c7d64 (patch)
tree6b4e7c974ba6841fe45b589c1711d331fed07c08
parente3207b13ce5acbae89441e06c19ae4df7988004e (diff)
downloademacs-fedaf25bb3b36e8bb85ba72a69e06117842c7d64.tar.gz
emacs-fedaf25bb3b36e8bb85ba72a69e06117842c7d64.zip
Simplify use of Tramp messages
* doc/misc/tramp.texi (Traces and Profiles): Don't require a minimum `tramp-verbose' level when `tramp-debug-command-messages' is non-nil. * lisp/net/tramp-message.el (tramp-debug-command-messages): Adapt docstring. (tramp-message, with-tramp-debug-message): Don't require a minimum `tramp-verbose' level when `tramp-debug-command-messages' is non-nil.
-rw-r--r--doc/misc/tramp.texi5
-rw-r--r--lisp/net/tramp-message.el88
2 files changed, 47 insertions, 46 deletions
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index 291d6600af5..6189ef2d41d 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -6125,9 +6125,8 @@ performance of @value{tramp} actions.
6125If @code{tramp-verbose} is greater than or equal to 11, @value{tramp} 6125If @code{tramp-verbose} is greater than or equal to 11, @value{tramp}
6126function call traces are written to the buffer @file{*trace tramp/foo*}. 6126function call traces are written to the buffer @file{*trace tramp/foo*}.
6127 6127
6128When @code{tramp-debug-command-messages} is non-@code{nil} and 6128When @code{tramp-debug-command-messages} is non-@code{nil}, the debug
6129@code{tramp-verbose} is greater than or equal to 6, the debug buffer 6129buffer contains all messages with verbosity level 6 (sent and received
6130contains all messages with verbosity level 6 (sent and received
6131strings), and the entry and exit messages for the function 6130strings), and the entry and exit messages for the function
6132@code{tramp-file-name-handler}. This is intended for @value{tramp} 6131@code{tramp-file-name-handler}. This is intended for @value{tramp}
6133maintainers, analyzing the remote commands for performance analysis. 6132maintainers, analyzing the remote commands for performance analysis.
diff --git a/lisp/net/tramp-message.el b/lisp/net/tramp-message.el
index cca22a28d7c..c91af638449 100644
--- a/lisp/net/tramp-message.el
+++ b/lisp/net/tramp-message.el
@@ -32,9 +32,8 @@
32;; This buffer is created when `tramp-verbose' is greater than or 32;; This buffer is created when `tramp-verbose' is greater than or
33;; equal 4. It contains all messages with a level up to `tramp-verbose'. 33;; equal 4. It contains all messages with a level up to `tramp-verbose'.
34;; 34;;
35;; When `tramp-debug-command-messages' is non-nil and 35;; When `tramp-debug-command-messages' is non-nil, the buffer
36;; `tramp-verbose' is greater than or equal 6, the buffer contains 36;; contains all messages with level 6 and the entry/exit messages of
37;; all messages with level 6 and the entry/exit messages of
38;; `tramp-file-name-handler'. This is intended to analyze which 37;; `tramp-file-name-handler'. This is intended to analyze which
39;; remote commands are sent for a given file name operation. 38;; remote commands are sent for a given file name operation.
40;; 39;;
@@ -85,7 +84,7 @@ The debug file has the same name as the debug buffer, written to
85 84
86(defcustom tramp-debug-command-messages nil 85(defcustom tramp-debug-command-messages nil
87 "Whether to write only command messages to the debug buffer. 86 "Whether to write only command messages to the debug buffer.
88This has only effect if `tramp-verbose' is greater than or equal 6." 87This increases `tramp-verbose' to 6 if necessary."
89 :group 'tramp 88 :group 'tramp
90 :version "30.1" 89 :version "30.1"
91 :type 'boolean) 90 :type 'boolean)
@@ -298,44 +297,47 @@ control string and the remaining ARGUMENTS to actually emit the message (if
298applicable)." 297applicable)."
299 ;; (declare (tramp-suppress-trace t)) 298 ;; (declare (tramp-suppress-trace t))
300 (ignore-errors 299 (ignore-errors
301 (when (<= level tramp-verbose) 300 (let ((tramp-verbose
302 ;; Display only when there is a minimum level, and the progress 301 (if tramp-debug-command-messages
303 ;; reporter doesn't suppress further messages. 302 (max tramp-verbose 6) tramp-verbose)))
304 (when (and (<= level 3) (null tramp-inhibit-progress-reporter)) 303 (when (<= level tramp-verbose)
305 (apply #'message 304 ;; Display only when there is a minimum level, and the
306 (concat 305 ;; progress reporter doesn't suppress further messages.
307 (cond 306 (when (and (<= level 3) (null tramp-inhibit-progress-reporter))
308 ((= level 0) "") 307 (apply #'message
309 ((= level 1) "") 308 (concat
310 ((= level 2) "Warning: ") 309 (cond
311 (t "Tramp: ")) 310 ((= level 0) "")
312 fmt-string) 311 ((= level 1) "")
313 arguments)) 312 ((= level 2) "Warning: ")
314 ;; Log only when there is a minimum level. 313 (t "Tramp: "))
315 (when (>= tramp-verbose 4) 314 fmt-string)
316 (let ((tramp-verbose 0)) 315 arguments))
317 ;; Append connection buffer for error messages, if exists. 316 ;; Log only when there is a minimum level.
318 (when (= level 1) 317 (when (>= tramp-verbose 4)
319 (ignore-errors 318 (let ((tramp-verbose 0))
320 (setq fmt-string (concat fmt-string "\n%s") 319 ;; Append connection buffer for error messages, if exists.
321 arguments 320 (when (= level 1)
322 (append 321 (ignore-errors
323 arguments 322 (setq fmt-string (concat fmt-string "\n%s")
324 `(,(tramp-get-buffer-string 323 arguments
325 (if (processp vec-or-proc) 324 (append
326 (process-buffer vec-or-proc) 325 arguments
327 (tramp-get-connection-buffer 326 `(,(tramp-get-buffer-string
328 vec-or-proc 'dont-create)))))))) 327 (if (processp vec-or-proc)
329 ;; Translate proc to vec. 328 (process-buffer vec-or-proc)
330 (when (processp vec-or-proc) 329 (tramp-get-connection-buffer
331 (setq vec-or-proc (process-get vec-or-proc 'tramp-vector)))) 330 vec-or-proc 'dont-create))))))))
332 ;; Do it. 331 ;; Translate proc to vec.
333 (when (and (tramp-file-name-p vec-or-proc) 332 (when (processp vec-or-proc)
334 (or (null tramp-debug-command-messages) (= level 6))) 333 (setq vec-or-proc (process-get vec-or-proc 'tramp-vector))))
335 (apply #'tramp-debug-message 334 ;; Do it.
336 vec-or-proc 335 (when (and (tramp-file-name-p vec-or-proc)
337 (concat (format "(%d) # " level) fmt-string) 336 (or (null tramp-debug-command-messages) (= level 6)))
338 arguments)))))) 337 (apply #'tramp-debug-message
338 vec-or-proc
339 (concat (format "(%d) # " level) fmt-string)
340 arguments)))))))
339 341
340;; We cannot use the `declare' form for `tramp-suppress-trace' in 342;; We cannot use the `declare' form for `tramp-suppress-trace' in
341;; autoloaded functions, because the tramp-loaddefs.el generation 343;; autoloaded functions, because the tramp-loaddefs.el generation
@@ -531,7 +533,7 @@ Bound in `tramp-*-file-name-handler' functions.")
531If BODY does not raise a debug message, MESSAGE is ignored." 533If BODY does not raise a debug message, MESSAGE is ignored."
532 (declare (indent 2) (debug t)) 534 (declare (indent 2) (debug t))
533 (let ((result (make-symbol "result"))) 535 (let ((result (make-symbol "result")))
534 `(if (and tramp-debug-command-messages (>= tramp-verbose 6)) 536 `(if tramp-debug-command-messages
535 (save-match-data 537 (save-match-data
536 (let ((tramp-debug-nesting 538 (let ((tramp-debug-nesting
537 (concat tramp-debug-nesting "#")) 539 (concat tramp-debug-nesting "#"))