tweak(lib): prevent redundant timestamps in logs

This commit is contained in:
Henrik Lissner 2022-09-10 18:27:01 +02:00
parent 78af0eeecb
commit ce0e3a04b6
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -165,14 +165,15 @@ symbol and CDR is the value to set it to when `doom-debug-mode' is activated.")
;;
;;; Time-stamped *Message* logs
(defun doom--timestamped-message-a (format-string &rest args)
(defun doom--timestamped-message-a (format-string &rest _args)
"Advice to run before `message' that prepends a timestamp to each message.
Activate this advice with:
(advice-add 'message :before 'doom--timestamped-message-a)"
(when (and (stringp format-string)
message-log-max
(not (string-equal format-string "%s%s")))
message-log-max ; if nil, logging is disabled
(not (equal format-string "%s%s"))
(not (equal format-string "\n")))
(with-current-buffer "*Messages*"
(let ((timestamp (format-time-string "[%F %T] " (current-time)))
(deactivate-mark nil))