GNU bug report logs -
#79168
30.1; Proposed changes for oauth2
Previous Next
Full log
View this message in rfc822 format
* packages/oauth2/oauth2.el: Add oauth2--do-warn, oauth2--do-trivia.
* packages/oauth2/oauth2.el (oauth2-make-access-request): Use
oauth2--do-trivia for detailed logging.
---
oauth2.el | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/oauth2.el b/oauth2.el
index 6f7b6a27db..eb2ae0cb9b 100644
--- a/oauth2.el
+++ b/oauth2.el
@@ -65,11 +65,24 @@
(defvar oauth2--url-advice nil)
(defvar oauth2--token-data)
+(defun oauth2--do-warn (&rest msg)
+ "Actual function to log MSG based on how `oauth2-debug' is set."
+ (setcar msg (concat "[oauth2] " (car msg)))
+ (apply (if (functionp oauth2-debug)
+ oauth2-debug
+ 'message)
+ msg))
+
+(defun oauth2--do-trivia (&rest msg)
+ "Output debug message when `oauth2-debug' is set to \\='trivia."
+ (when (or (eq oauth2-debug 'trivia)
+ (functionp oauth2-debug))
+ (apply #'oauth2--do-warn msg)))
+
(defun oauth2--do-debug (&rest msg)
"Output debug messages when `oauth2-debug' is enabled."
(when oauth2-debug
- (setcar msg (concat "[oauth2] " (car msg)))
- (apply #'message msg)))
+ (apply #'oauth2--do-warn msg)))
(defun oauth2-request-authorization (auth-url client-id &optional scope state
redirect-uri)
@@ -109,8 +122,8 @@ Returns the code provided by the service."
(defun oauth2-make-access-request (url data)
"Make an access request to URL using DATA in POST requests."
(let ((func-name (nth 1 (backtrace-frame 2))))
- (oauth2--do-debug "%s: url: %s" func-name url)
- (oauth2--do-debug "%s: data: %s" func-name data)
+ (oauth2--do-trivia "%s: url: %s" func-name url)
+ (oauth2--do-trivia "%s: data: %s" func-name data)
(let ((url-request-method "POST")
(url-request-data data)
(url-request-extra-headers
@@ -118,7 +131,8 @@ Returns the code provided by the service."
(with-current-buffer (url-retrieve-synchronously url)
(let ((data (oauth2-request-access-parse)))
(kill-buffer (current-buffer))
- (oauth2--do-debug "%s: response: %s" func-name (prin1-to-string data))
+ (oauth2--do-trivia "%s: response: %s" func-name
+ (prin1-to-string data))
data)))))
(cl-defstruct oauth2-token
--
2.39.5
This bug report was last modified today.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.