How to pass &rest arguments to another function in emacs lisp?

What you need is apply:

(defun log4me (level logmsg &rest formatparams)
  "Log message."
  (interactive)
  (when (<= level log4elisp::loglevel)
    (apply #'message logmsg formatparams)))

apply is perfect for functions, but is invalid for function-objects like macros. The following solution is applicable for both functions and macros.

(defun log4me (level logmsg &rest formatparams)
  "Log message."
  (interactive)
  (when (<= level log4elisp::loglevel)
    (eval (append '(message logmsg) formatparams))))

Tags:

Emacs

Elisp