Function: tramp-debug-message
tramp-debug-message is a byte-compiled function defined in
tramp-message.el.gz.
Signature
(tramp-debug-message VEC FMT-STRING &rest ARGUMENTS)
Documentation
Append message to debug buffer of VEC.
Message is formatted with FMT-STRING as control string and the remaining ARGUMENTS to actually emit the message (if applicable).
Source Code
;; Defined in /usr/src/emacs/lisp/net/tramp-message.el.gz
(defun tramp-debug-message (vec fmt-string &rest arguments)
"Append message to debug buffer of VEC.
Message is formatted with FMT-STRING as control string and the remaining
ARGUMENTS to actually emit the message (if applicable)."
(declare (tramp-suppress-trace t))
(let ((inhibit-message t)
create-lockfiles file-name-handler-alist message-log-max
signal-hook-function)
(with-current-buffer (tramp-get-debug-buffer vec)
(goto-char (point-max))
(let ((point (point)))
(when (bobp)
;; Headline.
(insert
(format
";; Emacs: %s Tramp: %s -*- mode: outline; coding: utf-8; -*-"
emacs-version tramp-version))
(when (>= tramp-verbose 10)
(let ((tramp-verbose 0))
(insert
(format
"\n;; Location: %s Git: %s/%s"
(locate-library "tramp")
(or tramp-repository-branch "")
(or tramp-repository-version "")))))
;; Traces.
(when (>= tramp-verbose 11)
(dolist
(elt
(append
(mapcar
#'intern (all-completions "tramp-" obarray #'functionp))
tramp-trace-functions))
(unless (get elt 'tramp-suppress-trace)
(trace-function-background elt (tramp-trace-buffer-name vec)))))
;; Delete debug file. Announce its further existence.
(when (and tramp-debug-to-file (tramp-get-debug-file-name vec))
(ignore-errors (delete-file (tramp-get-debug-file-name vec)))
(let ((message-log-max t))
(message
"Tramp debug file is %s" (tramp-get-debug-file-name vec)))))
(unless (bolp)
(insert "\n"))
;; Timestamp.
(insert (format-time-string "%T.%6N "))
;; Threads. `current-thread' might not exist when Emacs is
;; configured --without-threads.
;; (unless (eq (tramp-compat-funcall 'current-thread) main-thread)
;; (insert (format "%s " (tramp-compat-funcall 'current-thread))))
;; Calling Tramp function. We suppress compat and trace
;; functions from being displayed.
(let ((frames (backtrace-frames))
btf fn)
(while (not fn)
(setq btf (cadadr frames))
(if (not btf)
(setq fn "")
(and (symbolp btf) (setq fn (symbol-name btf))
(or (not (string-prefix-p "tramp" fn))
(get btf 'tramp-suppress-trace))
(setq fn nil))
(setq frames (cdr frames))))
;; The following code inserts filename and line number.
;; Should be inactive by default, because it is time consuming.
;; (let ((ffn (find-function-noselect (intern fn))))
;; (insert
;; (format
;; "%s:%d: "
;; (file-name-nondirectory (buffer-file-name (car ffn)))
;; (with-current-buffer (car ffn)
;; (1+ (count-lines (point-min) (cdr ffn)))))))
(insert (format "%s " fn)))
;; The message.
(insert (apply #'format-message fmt-string arguments))
(if tramp-debug-command-messages
;; Add help function.
(tramp-debug-message-buttonize point)
;; Write message to debug file.
(when tramp-debug-to-file
(ignore-errors
(write-region
point (point-max) (tramp-get-debug-file-name vec) 'append))))))))