New doom-log macro for debug-time logging
doom-log won't interfere with the minibuffer if it's in use, and will report the originating module. Addresses #1215
This commit is contained in:
parent
9266239a2f
commit
f6cc2644b0
7 changed files with 32 additions and 22 deletions
|
@ -262,8 +262,7 @@ Used by `doom-packages-update'."
|
|||
;; asynchronously.
|
||||
(let (futures)
|
||||
(dolist (pkg quelpa-pkgs)
|
||||
(when doom-debug-mode
|
||||
(message "New thread for: %s" pkg))
|
||||
(doom-log "New thread for: %s" pkg)
|
||||
(push (async-start
|
||||
`(lambda ()
|
||||
(let ((gc-cons-threshold ,doom-gc-cons-upper-limit)
|
||||
|
|
|
@ -102,6 +102,22 @@ This is used by `associate!', `file-exists-p!' and `project-file-exists-p!'."
|
|||
(cl-check-type :test keyword)
|
||||
(substring (symbol-name keyword) 1))
|
||||
|
||||
(defmacro doom-log (format-string &rest args)
|
||||
"Log to *Messages* if `doom-debug-mode' is on.
|
||||
Does not interrupt the minibuffer if it is in use, but still logs to *Messages*.
|
||||
Accepts the same arguments as `message'."
|
||||
(when doom-debug-mode
|
||||
`(let ((inhibit-message (active-minibuffer-window)))
|
||||
(message
|
||||
,(concat (propertize "DOOM " 'face 'font-lock-comment-face)
|
||||
format-string
|
||||
(when doom--current-module
|
||||
(propertize (format " [%s/%s]"
|
||||
(doom-keyword-name (car doom--current-module))
|
||||
(cdr doom--current-module))
|
||||
'face 'warning)))
|
||||
,@args))))
|
||||
|
||||
(defun FILE! ()
|
||||
"Return the emacs lisp file this macro is called from."
|
||||
(cond ((bound-and-true-p byte-compile-current-file))
|
||||
|
|
|
@ -250,8 +250,7 @@ non-nil, return paths of possible modules, activated or otherwise."
|
|||
(use-package-concat
|
||||
`((fset ',fn
|
||||
(lambda (&rest _)
|
||||
(when doom-debug-mode
|
||||
(message "Loading deferred package %s from %s" ',name ',fn))
|
||||
(doom-log "Loading deferred package %s from %s" ',name ',fn)
|
||||
(condition-case e (require ',name)
|
||||
((debug error)
|
||||
(message "Failed to load deferred package %s: %s" ',name e)))
|
||||
|
|
19
core/core.el
19
core/core.el
|
@ -264,7 +264,7 @@ If you want to disable incremental loading altogether, either remove
|
|||
|
||||
Set this to nil to disable incremental loading.")
|
||||
|
||||
(defvar doom-incremental-idle-timer 1
|
||||
(defvar doom-incremental-idle-timer 1.5
|
||||
"How long (in idle seconds) in between incrementally loading packages.")
|
||||
|
||||
(defun doom-load-packages-incrementally (packages &optional now)
|
||||
|
@ -280,17 +280,17 @@ intervals."
|
|||
(let* ((reqs (cl-delete-if #'featurep packages))
|
||||
(req (ignore-errors (pop reqs))))
|
||||
(when req
|
||||
(when doom-debug-mode
|
||||
(message "Incrementally loading %s" req))
|
||||
(doom-log "Incrementally loading %s" req)
|
||||
(condition-case e
|
||||
(require req nil t)
|
||||
(error
|
||||
((error debug)
|
||||
(message "Failed to load '%s' package incrementally, because: %s"
|
||||
req e)))
|
||||
(when reqs
|
||||
(run-with-idle-timer doom-incremental-idle-timer
|
||||
nil #'doom-load-packages-incrementally
|
||||
reqs t))))))))
|
||||
(if reqs
|
||||
(run-with-idle-timer doom-incremental-idle-timer
|
||||
nil #'doom-load-packages-incrementally
|
||||
reqs t)
|
||||
(doom-log "Finished incremental loading"))))))))
|
||||
|
||||
(defun doom|load-packages-incrementally ()
|
||||
"Begin incrementally loading packages in `doom-incremental-packages'.
|
||||
|
@ -314,8 +314,7 @@ If this is a daemon session, load them all immediately instead."
|
|||
issues easier.
|
||||
|
||||
Meant to be used with `run-hook-wrapped'."
|
||||
(when doom-debug-mode
|
||||
(message "Running doom hook: %s" hook))
|
||||
(doom-log "Running doom hook: %s" hook)
|
||||
(condition-case e
|
||||
(funcall hook)
|
||||
((debug error)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue