emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/xelb 599ef70: Add timestamps to XELB debug logs


From: Chris Feng
Subject: [elpa] externals/xelb 599ef70: Add timestamps to XELB debug logs
Date: Sun, 8 Sep 2019 09:06:41 -0400 (EDT)

branch: externals/xelb
commit 599ef709072c18022f5b08c0367721d126b1a716
Author: Chris Feng <address@hidden>
Commit: Chris Feng <address@hidden>

    Add timestamps to XELB debug logs
    
    * xcb-debug.el (xcb-debug:log-time-function): New user option for
    choosing the style of timestamps in debug logs.
    (xcb-debug:log-uptime, xcb-debug:log-time): Possible candidates for
    it.
    * xcb-types.el (xcb:-log): Use it.
---
 xcb-debug.el | 16 ++++++++++++++++
 xcb-types.el |  5 ++++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/xcb-debug.el b/xcb-debug.el
index 473c7ef..d9d017f 100644
--- a/xcb-debug.el
+++ b/xcb-debug.el
@@ -30,6 +30,22 @@
 (defvar xcb-debug:backtrace-start-frame 5
   "From which frame to start collecting backtraces.")
 
+(defvar xcb-debug:log-time-function #'xcb-debug:log-uptime
+  "Function used for generating timestamps in XELB debug logs.
+
+Here are some predefined candidates:
+`xcb-debug:log-uptime': Display the uptime of this Emacs instance.
+`xcb-debug:log-time': Display time of day.
+`nil': Disable timestamp.")
+
+(defun xcb-debug:log-uptime ()
+  "Add uptime to XELB debug logs."
+  (emacs-uptime "[%.2h:%.2m:%.2s] "))
+
+(defun xcb-debug:log-time ()
+  "Add time of day to XELB debug logs."
+  (format-time-string "[%T] "))
+
 (defun xcb-debug:-call-stack ()
   "Return the current call stack frames."
   (let (frames frame
diff --git a/xcb-types.el b/xcb-types.el
index 82854fd..c9f60f1 100644
--- a/xcb-types.el
+++ b/xcb-types.el
@@ -64,7 +64,10 @@ FORMAT-STRING is a string specifying the message to output, 
as in
 `format'.  The OBJECTS arguments specify the substitutions."
   (unless format-string (setq format-string ""))
   `(when xcb:debug
-     (xcb-debug:message ,(concat "%s:\t" format-string "\n")
+     (xcb-debug:message ,(concat "%s%s:\t" format-string "\n")
+                        (if xcb-debug:log-time-function
+                            (funcall xcb-debug:log-time-function)
+                          "")
                         (xcb-debug:compile-time-function-name)
                         ,@objects)
      nil))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]