Function: nrepl-log-message

nrepl-log-message is a byte-compiled function defined in nrepl-client.el.

Signature

(nrepl-log-message MSG TYPE)

Documentation

Log the nREPL MSG.

TYPE is either request or response. The message is logged to a buffer described by nrepl-message-buffer-name-template.

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20260414.1619/nrepl-client.el
(defun nrepl-log-message (msg type)
  "Log the nREPL MSG.
TYPE is either request or response.  The message is logged to a buffer
described by `nrepl-message-buffer-name-template'."
  (when nrepl-log-messages
    ;; append a time-stamp to the message before logging it
    ;; the time-stamps are quite useful for debugging
    (setq msg (cons (car msg)
                    (cider-plist-put (cdr msg) "time-stamp"
                                     (format-time-string "%Y-%m-%0d %H:%M:%S.%N"))))
    (with-current-buffer (nrepl-messages-buffer (current-buffer))
      (setq buffer-read-only nil)
      (when (> (buffer-size) nrepl-message-buffer-max-size)
        (goto-char (/ (buffer-size) nrepl-message-buffer-reduce-denominator))
        (re-search-forward "^(" nil t)
        (delete-region (point-min) (- (point) 1)))
      (goto-char (point-max))
      (nrepl-log-pp-object (nrepl-decorate-msg msg type)
                           (nrepl-log--message-color (cider-plist-get (cdr msg) "id"))
                           t)
      (when-let* ((win (get-buffer-window)))
        (set-window-point win (point-max)))
      (setq buffer-read-only t))))