From 8c120d41f1a202105175503629aa79b2808421d2 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Sat, 9 May 2020 21:29:17 -0500 Subject: added logging switch and stream --- lazybones.lisp | 8 ++++++++ package.lisp | 2 ++ 2 files changed, 10 insertions(+) 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 -- cgit v1.2.3