branch: elpa/emacsql
commit 2fa32d2ab7a8542091868f475716c707acc5eca0
Author: Jonas Bernoulli <jo...@bernoul.li>
Commit: Jonas Bernoulli <jo...@bernoul.li>

    Create new log buffer if existing one isn't live anymore
    
    The user might have killed the log buffer, in which case we have
    to create a new one, if logging is enabled.
    
    Closes #60.
    Closes #62.
---
 emacsql.el | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/emacsql.el b/emacsql.el
index 5f180f0a10..7b93c4c819 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -130,11 +130,13 @@ SQL expression.")
 (cl-defmethod emacsql-log ((connection emacsql-connection) message)
   "Log MESSAGE into CONNECTION's log.
 MESSAGE should not have a newline on the end."
-  (let ((log (emacsql-log-buffer connection)))
-    (when log
-      (with-current-buffer log
+  (let ((buffer (emacsql-log-buffer connection)))
+    (when buffer
+      (unless (buffer-live-p buffer)
+        (setq buffer (emacsql-enable-debugging connection)))
+      (with-current-buffer buffer
         (setf (point) (point-max))
-        (princ (concat message "\n") log)))))
+        (princ (concat message "\n") buffer)))))
 
 ;;; Sending and receiving
 

Reply via email to