aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Okay <cbeok@protonmail.com>2020-05-09 21:29:17 -0500
committerColin Okay <cbeok@protonmail.com>2020-05-09 21:29:17 -0500
commit8c120d41f1a202105175503629aa79b2808421d2 (patch)
tree67582b5193a13c8d2faf554177d2558bba0d9f7e
parent22dd2e7c2614092287f05305a0d9367751ba85f3 (diff)
added logging switch and stream
-rw-r--r--lazybones.lisp8
-rw-r--r--package.lisp2
2 files changed, 10 insertions, 0 deletions
diff --git a/lazybones.lisp b/lazybones.lisp
index 318ae95..92f6d93 100644
--- a/lazybones.lisp
+++ b/lazybones.lisp
@@ -20,6 +20,12 @@ If no known decoder matches, holds a stream.
Bound by route handlers for POST, PUT, and PATCH requests.")
+(defvar *logging-p* nil
+ "Set to T if you want ot log requests to the value of *logging-stream*.")
+
+(defvar *logging-stream* t
+ "Set to T (i.e the standard output) by default.")
+
(defvar *resp-headers* nil
"A PLIST bound at the beginning of every response. Can be used to
add additional headers to responses valid responses.")
@@ -260,6 +266,8 @@ for the request's path."
(defun main-handler (req)
+ (when *logging-p*
+ (format *logging-stream* "~a~%" req))
(handler-case
(multiple-value-bind (args handler) (lookup-route req)
(if handler
diff --git a/package.lisp b/package.lisp
index 102cff9..46113bc 100644
--- a/package.lisp
+++ b/package.lisp
@@ -13,6 +13,8 @@
#:*body*
#:*req*
#:*resp-headers*
+ #:*logging-p*
+ #:*logging-stream*
#:add-decoder
#:add-header
#:defroute