ba758da80c62
Minor utils cleanup
author | Steve Losh <steve@stevelosh.com> |
---|---|
date | Sun, 21 Aug 2016 11:49:22 +0000 |
parents | b7a399c67d24 |
children | 2b76060dba22 |
branches/tags | (none) |
files | src/server.lisp src/utils.lisp |
Changes
--- a/src/server.lisp Sun Aug 21 11:42:23 2016 +0000 +++ b/src/server.lisp Sun Aug 21 11:49:22 2016 +0000 @@ -39,23 +39,23 @@ (defun handle (message) "Handle the given NREPL message." (when *verbose-debug-output* - (l "Handling message: vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv~%") - (l "~A~%" message) - (l "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^~%")) + (log-message "Handling message: vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv~%") + (log-message "~A~%" message) + (log-message "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^~%")) (funcall (build-handler #'handle-base (middleware)) message)) (defun handle-message (socket-stream lock) "Read and handle a single message from the socket." (let ((message (fset:with (read-object socket-stream) - "transport" (curry #'write-object socket-stream lock)))) + "transport" (partial #'write-object socket-stream lock)))) (handle message))) (defun handler (socket-stream lock) "Read a series of messages from the socket-stream, handling each." - (p "Client connected...") + (log-message "Client connected...") (handler-case (loop (handle-message socket-stream lock)) (end-of-file () nil)) - (p "Client disconnected...")) + (log-message "Client disconnected...")) ;;;; Server
--- a/src/utils.lisp Sun Aug 21 11:42:23 2016 +0000 +++ b/src/utils.lisp Sun Aug 21 11:49:22 2016 +0000 @@ -33,9 +33,9 @@ (read-next-from-string (subseq s pos) (cons i results)))))) (nreverse (read-next-from-string s ())))) -(defun curry (fn &rest curried-args) - (lambda (&rest args) - (apply fn (append curried-args args)))) +(defun partial (fn &rest args) + (lambda (&rest remaining-args) + (apply fn (append args remaining-args)))) (defun random-uuid () "Return a random UUID as a string." @@ -46,12 +46,9 @@ :collect key)) -(defun l (&rest args) - (apply #'format *log* args)) - -(defun p (o) - (format *log* "~a~%" o) - o) +(defun log-message (&rest args) + (apply #'format *log* args) + (force-output *log*)) (defun respond (message response) @@ -67,11 +64,11 @@ "session" (fset:lookup message "session")))) -(defmethod print-object ((object hash-table) stream) - (format stream "#HASH{~%~{~{ (~s : ~s)~}~%~}}" - (loop :for key :being :the :hash-keys :of object - :using (hash-value value) - :collect (list key value)))) +; (defmethod print-object ((object hash-table) stream) +; (format stream "#HASH{~%~{~{ (~s : ~s)~}~%~}}" +; (loop :for key :being :the :hash-keys :of object +; :using (hash-value value) +; :collect (list key value)))) (defun parse-in-package (in-package) (if (null in-package)