From 2d36241a10b4b705e1482322383f135bca7ac184 Mon Sep 17 00:00:00 2001 From: Chris Feng Date: Sun, 8 Sep 2019 00:00:00 +0000 Subject: Add timestamps to `exwm-debug' logs * exwm-core.el (exwm-debug-log-time-function): New user option for choosing the style of timestamps in debug logs. (exwm-debug-log-uptime, exwm-debug-log-time): Possible candidates for it. (exwm--log): Use it. --- exwm-core.el | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'exwm-core.el') diff --git a/exwm-core.el b/exwm-core.el index d3edb146ec99..ed9a523448bc 100644 --- a/exwm-core.el +++ b/exwm-core.el @@ -33,6 +33,27 @@ (require 'xcb-ewmh) (require 'xcb-debug) +(defcustom exwm-debug-log-time-function #'exwm-debug-log-uptime + "Function used for generating timestamps in `exwm-debug' logs. + +Here are some predefined candidates: +`exwm-debug-log-uptime': Display the uptime of this Emacs instance. +`exwm-debug-log-time': Display time of day. +`nil': Disable timestamp." + :group 'exwm + :type `(choice (const :tag "Emacs uptime" ,#'exwm-debug-log-uptime) + (const :tag "Time of day" ,#'exwm-debug-log-time) + (const :tag "Off" nil) + (function :tag "Other"))) + +(defun exwm-debug-log-uptime () + "Add uptime to `exwm-debug' logs." + (emacs-uptime "[%.2h:%.2m:%.2s] ")) + +(defun exwm-debug-log-time () + "Add time of day to `exwm-debug' logs." + (format-time-string "[%T] ")) + (defvar exwm--connection nil "X connection.") (defvar exwm--wmsn-window nil @@ -79,7 +100,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 exwm-debug - (xcb-debug:message ,(concat "%s:\t" format-string "\n") + (xcb-debug:message ,(concat "%s%s:\t" format-string "\n") + (if exwm-debug-log-time-function + (funcall exwm-debug-log-time-function) + "") (xcb-debug:compile-time-function-name) ,@objects) nil)) -- cgit 1.4.1