]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve Tramp debug messages
authorMichael Albinus <michael.albinus@gmx.de>
Sun, 3 May 2020 11:59:08 +0000 (13:59 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Sun, 3 May 2020 11:59:08 +0000 (13:59 +0200)
* lisp/net/tramp-cache.el (tramp-get-file-property)
(tramp-get-connection-property): Improve debug messages.
Suggested by Marc Herbert <marc.herbert@gmail.com>.

lisp/net/tramp-cache.el

index 14a64382acbc57a08de8cb1b36d20c31183ce630..02400f9deb51554c3913a8bfc42d8e2720840466 100644 (file)
@@ -139,23 +139,29 @@ Return DEFAULT if not set."
        (tramp-run-real-handler #'directory-file-name (list file))
        (tramp-file-name-hop key) nil)
   (let* ((hash (tramp-get-hash-table key))
-        (value (when (hash-table-p hash) (gethash property hash))))
-    (if ;; We take the value only if there is any, and
-       ;; `remote-file-name-inhibit-cache' indicates that it is still
-       ;; valid.  Otherwise, DEFAULT is set.
-       (and (consp value)
+        (cached (and (hash-table-p hash) (gethash property hash)))
+        (cached-at (and (consp cached) (format-time-string "%T" (car cached))))
+        (value default)
+        use-cache)
+
+    (when ;; We take the value only if there is any, and
+         ;; `remote-file-name-inhibit-cache' indicates that it is
+         ;; still valid.  Otherwise, DEFAULT is set.
+       (and (consp cached)
             (or (null remote-file-name-inhibit-cache)
                 (and (integerp remote-file-name-inhibit-cache)
                      (time-less-p
                       nil
-                      (time-add (car value) remote-file-name-inhibit-cache)))
+                      (time-add (car cached) remote-file-name-inhibit-cache)))
                 (and (consp remote-file-name-inhibit-cache)
                      (time-less-p
-                      remote-file-name-inhibit-cache (car value)))))
-       (setq value (cdr value))
-      (setq value default))
+                      remote-file-name-inhibit-cache (car cached)))))
+      (setq value (cdr cached)
+           use-cache t))
 
-    (tramp-message key 8 "%s %s %s" file property value)
+    (tramp-message key 8 "%s %s %s; inhibit: %s; cache used: %s; cached at: %s"
+                   file property value
+                  remote-file-name-inhibit-cache use-cache cached-at)
     (when (>= tramp-verbose 10)
       (let* ((var (intern (concat "tramp-cache-get-count-" property)))
             (val (or (numberp (bound-and-true-p var))
@@ -310,15 +316,19 @@ the connection, return DEFAULT."
     (setf (tramp-file-name-localname key) nil
          (tramp-file-name-hop key) nil))
   (let* ((hash (tramp-get-hash-table key))
-        (value
-         ;; If the key is an auxiliary process object, check whether
-         ;; the process is still alive.
-         (if (and (processp key) (not (process-live-p key)))
-             default
-           (if (hash-table-p hash)
-               (gethash property hash default)
-             default))))
-    (tramp-message key 7 "%s %s" property value)
+        (cached (if (hash-table-p hash)
+                    (gethash property hash tramp-cache-undefined)
+                  tramp-cache-undefined))
+        (value default)
+        use-cache)
+
+    (when (and (not (eq cached tramp-cache-undefined))
+              ;; If the key is an auxiliary process object, check
+              ;; whether the process is still alive.
+              (not (and (processp key) (not (process-live-p key)))))
+      (setq value cached
+           use-cache t))
+    (tramp-message key 7 "%s %s; cache used: %s" property value use-cache)
     value))
 
 ;;;###tramp-autoload