diff options
author | Teddy Wing | 2021-02-27 15:55:22 +0100 |
---|---|---|
committer | Teddy Wing | 2021-02-27 15:55:22 +0100 |
commit | 3380e4e3af7a1e5d51d018e616ed990a8556d498 (patch) | |
tree | aaec744f6c8beef271a08cd54231d4c1f1696b0a | |
parent | 133e81bc8e51152c574356849c1798ba2bc3a259 (diff) | |
download | extreload-3380e4e3af7a1e5d51d018e616ed990a8556d498.tar.bz2 |
Hide `websocket-send` debug output behind `--debug` flag
Make the config containing command line options a global variable. This
makes it easy to find out if the `--debug` flag is on in the
`websocket-send` function.
Not sure about the global variable, but seems fine for now.
-rw-r--r-- | l/src/main.lisp | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/l/src/main.lisp b/l/src/main.lisp index f6b7d07..9eaa8e3 100644 --- a/l/src/main.lisp +++ b/l/src/main.lisp @@ -34,23 +34,24 @@ (handler-bind ((error #'(lambda (e) (exit-with-error e sysexits:+unavailable+)))) - (let ((config (parse-options))) - ;; Store the WebSocket client as a global. - (defvar *client* (ws-client config)) + ;; Store the config as a global. + (defvar *config* (parse-options)) - (trivial-timeout:with-timeout (+timeout-seconds+) - (with-websocket-connection (*client*) - (wsd:on :message *client* - #'(lambda (message) - (ws-on-message - message - (extension-ids config) - config))) + (trivial-timeout:with-timeout (+timeout-seconds+) + (with-websocket-connection ((ws-client *config*)) + (wsd:on :message (ws-client *config*) + #'(lambda (message) + (ws-on-message + message + (extension-ids *config*) + *config*))) - (websocket-send *client* (target-get-targets-msg - (next-call-id *devtools-root-call-id*))) + (websocket-send + (ws-client *config*) + (target-get-targets-msg + (next-call-id *devtools-root-call-id*))) - (wait-group:wait *wg*)))))) + (wait-group:wait *wg*))))) (defun ws-on-message (message extension-ids config) (let* ((response (jsown:parse message)) @@ -109,7 +110,7 @@ (defun attach-to-target (extension) (let ((target-id (json-obj-get extension "targetId"))) - (websocket-send *client* + (websocket-send (ws-client *config*) (target-attach-to-target-msg (next-call-id *devtools-root-call-id*) target-id)))) @@ -117,7 +118,7 @@ (defun reload-extension (session-id) (setf *last-session-id* session-id) (websocket-send - *client* + (ws-client *config*) (runtime-evaluate-msg (next-call-id *devtools-secondary-call-id*) session-id @@ -131,7 +132,7 @@ (wait-group:add *wg*) (websocket-send - *client* + (ws-client *config*) (runtime-evaluate-msg (next-call-id *devtools-secondary-call-id*) session-id @@ -145,7 +146,8 @@ (filter #'extensionp targets))) (defun websocket-send (client data) - (format t "Sending: ~a~%" data) + (when (debug-output *config*) + (format t "Sending: ~a~%" data)) (wsd:send client data) (wait-group:add *wg*)) |