Last active
October 7, 2020 20:43
-
-
Save hyotang666/7598f4a03dde28feaec9a4e2f252410e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defvar *logs* (make-hash-table :test #'equal)) | |
(defmacro log! (&rest names) | |
(if (null names) | |
`(progn (maphash (lambda (name function) | |
(setf (fdefinition name) function)) | |
*logs*) | |
(clrhash *logs*)) | |
`(map nil (lambda (name) | |
(if (gethash name *logs*) | |
(warn "Already logging: ~S" name) | |
(let ((function (fdefinition name))) | |
(setf (gethash name *logs*) function | |
(fdefinition name) | |
(lambda (&rest args) | |
(format *trace-output* "~%Start: ~S" name) | |
(unwind-protect (apply function args) | |
(format *trace-output* "~%End: ~S" name))))))) | |
',names))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment