I have a convinience defun in my init.el to do some logging
(defvar log4me::loglevel 5
"Global loglevel.")
(defun log4me (level logmsg)
"Log message."
(interactive)
(when (>= level log4elisp::loglevel)
(message logmsg))))
It kind of works but somehow i frequently do
(log4me somelevel (format "mymessage with %d" 1))
So i found the emacs lisp &rest parameters which i thought i might use like this:
(defun log4me (level logmsg &rest formatparams)
"Log message."
(interactive)
(when (<= level log4elisp::loglevel)
(message (format logmsg formatparams))))
(log4me 3 "Hello %ust!" 1)
which resuslts into "Format specifier doesn't match argument type" error since formatparams is actually (1) and not 1.
Is there a nice way to include format parameters into the log4elisp defun and make them arrive in the format function call as "normal" parameters (not a single list)?
Set aside enough time to study You will do well in examinations by making a timetable. This is one of the best ways to study. Make a timetable on which subjects to read on particular days of the week. Get to know if you read better in the morning or late at night and plan yourself accordingly.
What you need is apply
:
(defun log4me (level logmsg &rest formatparams)
"Log message."
(interactive)
(when (<= level log4elisp::loglevel)
(apply #'message logmsg formatparams)))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With