From 2dcb68486a49d59376778aea97a23ada1af5c1f4 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Tue, 14 Sep 2021 01:43:43 -0700 Subject: NOT A PATCH F. Jason Park (1): Add CRLF to outgoing ERC protocol logger lines lisp/erc/erc.el | 79 +++++++++++++++++++++++++------------- test/lisp/erc/erc-tests.el | 36 +++++++++++++++++ 2 files changed, 88 insertions(+), 27 deletions(-) Interdiff: diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 524a22e5a1..fe4ec52880 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -2317,7 +2317,16 @@ erc-debug-irc-protocol-time-format (defconst erc-debug-irc-protocol-version "1" "Protocol log format version number. -This is to help tooling track changes to the format.") +This exists to help tooling track changes to the format. + +In version 1, everything before and including the first double CRLF is +front matter, which must also be CRLF terminated. Lines beginning with +three asterisks must be ignored as comments. Other lines should be +interpreted as email-style headers. Folding is not supported. A second +double CRLF, if present, signals the end of a log. Session resumption +is not supported. Logger lines must adhere to the following format: +TIMESTAMP PEER-NAME FLOW-INDICATOR IRC-MESSAGE CRLF. Outgoing messages +are indicated with a >> and incoming with a <<.") (defvar erc-debug-irc-protocol nil "If non-nil, log all IRC protocol traffic to the buffer \"*erc-protocol*\". @@ -2344,11 +2353,7 @@ erc-log-irc-protocol appears in face `erc-input-face' in the buffer. Lines must already contain CRLF endings. Peer is identified by the most precise label available at run time, starting with the network name, followed by the -self-reported host name, and falling back to the dialed :. -When capturing logs for multiple peers and sorting them into buckets, -such inconsistent labeling may pose a problem during an initial server -burst. For now, the recommended approach is to wrap this function with -advice that temporarily redefines the symbol-function `erc-network'." +announced host name, and falling back to the dialed :." (when erc-debug-irc-protocol (let ((esid (or (and (fboundp 'erc-network) (erc-network) @@ -2382,23 +2387,22 @@ erc-log-irc-protocol (defun erc-toggle-debug-irc-protocol (&optional arg) "Toggle the value of `erc-debug-irc-protocol'. -If ARG is non-nil, show the *erc-protocol* buffer. Everything before -and including the first double CRLF is front matter. Everything before -the first double linefeed is a header." +If ARG is non-nil, show the *erc-protocol* buffer." (interactive "P") (let* ((buf (get-buffer-create "*erc-protocol*"))) (with-current-buffer buf (view-mode-enter) (when (null (current-local-map)) (let ((inhibit-read-only t) - (headers (concat "Version: " erc-debug-irc-protocol-version "\n" - "Emacs-Version: " emacs-version "\n" - "\n")) - (msg (concat "This buffer displays all IRC protocol traffic " - "exchanged with servers.\n" - "Kill it to disable logging.\n" - "Press `t' to toggle.\n"))) - (insert headers (erc-make-notice msg))) + (msg (list + (concat "Version: " erc-debug-irc-protocol-version) + (concat "Emacs-Version: " emacs-version) + (erc-make-notice + (concat "This buffer displays all IRC protocol " + "traffic exchanged with servers.")) + (erc-make-notice "Kill it to disable logging.") + (erc-make-notice "Press `t' to toggle.")))) + (insert (string-join msg "\r\n"))) (use-local-map (make-sparse-keymap)) (local-set-key (kbd "t") 'erc-toggle-debug-irc-protocol)) (add-hook 'kill-buffer-hook -- 2.31.1