Refactor the backend tracing code.
authorLars Ingebrigtsen <larsi@gnus.org>
Sun, 23 Dec 2012 07:48:55 +0000 (08:48 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Sun, 23 Dec 2012 07:49:27 +0000 (08:49 +0100)
* gnus-int.el (gnus-backend-trace): Factor out into its own function
for reuse.
(gnus-open-server): Use it to add more tracing.

lisp/ChangeLog
lisp/gnus-int.el

index 048a660..cfd3774 100644 (file)
@@ -1,3 +1,9 @@
+2012-12-23  Lars Ingebrigtsen  <larsi@gnus.org>
+
+       * gnus-int.el (gnus-backend-trace): Factor out into its own function
+       for reuse.
+       (gnus-open-server): Use it to add more tracing.
+
 2012-12-22  Philipp Haselwarter <philipp@haselwarter.org>
 
        * gnus-sync.el (gnus-sync-file-encrypt-to, gnus-sync-save): Set
index bc3ba18..101c29c 100644 (file)
@@ -249,16 +249,18 @@ If it is down, start it up (again)."
 
 (defvar gnus-backend-trace nil)
 
+(defun gnus-backend-trace (type form)
+  (with-current-buffer (get-buffer-create "*gnus trace*")
+    (buffer-disable-undo)
+      (goto-char (point-max))
+      (insert (format-time-string "%H:%M:%S")
+             (format " %s %S\n" type form))))
+
 (defun gnus-open-server (gnus-command-method)
   "Open a connection to GNUS-COMMAND-METHOD."
   (when (stringp gnus-command-method)
     (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
-  (when gnus-backend-trace
-    (with-current-buffer (get-buffer-create "*gnus trace*")
-      (buffer-disable-undo)
-      (goto-char (point-max))
-      (insert (format-time-string "%H:%M:%S")
-             (format " %S\n" gnus-command-method))))
+  (gnus-backend-trace :opening gnus-command-method)
   (let ((elem (assoc gnus-command-method gnus-opened-servers))
        (server (gnus-method-to-server-name gnus-command-method)))
     ;; If this method was previously denied, we just return nil.
@@ -333,6 +335,7 @@ If it is down, start it up (again)."
            (save-excursion
              (gnus-agent-possibly-synchronize-flags-server
               gnus-command-method)))
+         (gnus-backend-trace :opened gnus-command-method)
           result)))))
 
 (defun gnus-close-server (gnus-command-method)