From bknr@bknr.net Wed Feb 18 20:30:47 2009 From: BKNR Commits To: bknr-cvs@common-lisp.net Subject: [bknr-cvs] edi changed trunk/thirdparty/hunchentoot/ Date: Wed, 18 Feb 2009 21:28:27 +0100 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2027815849467171187==" --===============2027815849467171187== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Revision: 4281 Author: edi URL: http://bknr.net/trac/changeset/4281 Document logging U trunk/thirdparty/hunchentoot/acceptor.lisp U trunk/thirdparty/hunchentoot/doc/index.xml U trunk/thirdparty/hunchentoot/log.lisp U trunk/thirdparty/hunchentoot/request.lisp U trunk/thirdparty/hunchentoot/specials.lisp Modified: trunk/thirdparty/hunchentoot/acceptor.lisp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/thirdparty/hunchentoot/acceptor.lisp 2009-02-18 19:58:57 UTC (rev 4= 280) +++ trunk/thirdparty/hunchentoot/acceptor.lisp 2009-02-18 20:28:27 UTC (rev 4= 281) @@ -139,9 +139,9 @@ :accessor acceptor-message-logger :documentation "Designator for a function to call to log messages by the acceptor. It must accept a severity level for -the message, which will be one of :NOTICE, :INFO, or :WARNING, a -format string and an arbitary number of formatting arguments. This -slot defaults to a function which writes to the file determined by +the message, which will be one of :ERROR, :INFO, or :WARNING, a format +string and an arbitary number of formatting arguments. This slot +defaults to a function which writes to the file determined by *MESSAGE-LOG-PATHNAME* \(unless that value is NIL). =20 If the value of this slot is NIL, message logging is turned off for Modified: trunk/thirdparty/hunchentoot/doc/index.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/thirdparty/hunchentoot/doc/index.xml 2009-02-18 19:58:57 UTC (rev 4= 280) +++ trunk/thirdparty/hunchentoot/doc/index.xml 2009-02-18 20:28:27 UTC (rev 4= 281) @@ -384,6 +384,11 @@ =20 + + The current ACCEPTOR object in the context of a reques= t. + + + acceptor @@ -450,10 +455,10 @@ =20 - + acceptor - handler-selector + request-dispatcher =20 @@ -600,11 +605,10 @@ ACCEPTOR object and a LispWorks socket handle or a usoc= ket socket stream object in socket. It reads the request headers,= sets up the request and reply -objects, and hands over to (the unexported -function) PROCESS-REQUEST which selects and calls a -handler for the request and sends its reply to the client. This is -done in a loop until the stream has to be closed or until a connection -timeout occurs. +objects, and hands over to PROCESS-REQUEST which +selects and calls a handler for the request and sends its reply to the +client. This is done in a loop until the stream has to be closed or +until a connection timeout occurs. =20

It is probably not a good idea to re-implement this method until you @@ -1102,6 +1106,90 @@ =20 + +By default, Hunchentoot logs accesses and errors to two separate files +in the file system, but only if the special variables +*MESSAGE-LOG-PATHNAME* and *ACCESS-LOG-PATHNA= ME* are set accordingly. +Access logging is done in a format similar to what +the Apache web server can write so that logfile analysis using +standard tools is possible. Errors during request processing are +logged to a separate file. +

+The standard logging mechanism is deliberately simple and slow. The +log files are opened for each log entry and closed again after +writing, and access to them is protected by a global lock. If you +want more sophisticated logging, use +the :access-logger +and :message-logger +initargs of the acceptor class to establish your own logging +functions. See the docstrings of the corresponding slots for more +information. +

+

+Errors happening within a handler which are +not caught by the handler itself are handled by Hunchentoot by logging +them to the log file. +

+ + + log-level format-string=20 + rest + format-arguments + + result + + Convenience function which calls the message +logger of the current acceptor (if there is one) with the same +arguments it accepts. Returns NIL if there is no message +logger or whatever the message logger returns. +

+This is the function which Hunchentoot itself uses to log errors it +catches during request processing. +

+
+
+ + + +A designator for the pathname of the message log file used by the +default message logger. The initial value is NIL which +means that nothing will be logged! + + + + + +A designator for the pathname of the access log file used by the +default access logger. The initial value is = NIL which +means that nothing will be logged! + + + + + Whether Lisp errors in request handlers should be logg= ed. + + + + + Whether Lisp warnings in request handlers should be lo= gged. + + + + + Log level for Lisp errors. Should be one +of :ERROR (the default), :WARNING, +or :INFO. + + + + + Log level for Lisp warnings. +Should be one of :ERROR, :WARNING +(the default), or :INFO. + + + + =20 @@ -1113,16 +1201,7 @@ =20 - - The current ACCEPTOR object. - - - - A designator for the pathname of the access log file u= sed by the -LOG-ACCESS-TO-FILE function. The initial value is NIL which means -that nothingq will be logged. - - + A list of return codes the server should not treat as = an error - see *HANDLE-HTTP-ERRORS-P*. @@ -1202,28 +1281,7 @@ The external format used to compute the REQUEST object. - - Log level for Lisp errors. - - - - Log level for Lisp warnings. - - - - Whether Lisp errors should be logged. - - - - Whether Lisp warnings should be logged. - - - - A designator for the pathname of the message log file = used by the -LOG-MESSAGE-TO-FILE function. The initial value is NIL which means -that nothing will be logged. - - + A list of the request method types (as keywords) for w= hich Hunchentoot will try to compute POST-PARAMETERS. @@ -2018,17 +2076,6 @@ =20 =20 - - log-level format-string=20 - rest - format-arguments - - result - - Convenience function which calls the message logger of= the current -acceptor (if there is one) with the same arguments it accepts. - - pathspec @@ -2548,6 +2595,33 @@ name doesn't exist, it is created. + + + + request + + nil + + +This function is called by PROCESS-CONNECTION +after the incoming headers have been read. It selects and calls a +handler and sends the output of this handler to the client. It also +sets up simple error handling for the request handler. Note +that PROCESS-CONNECTION is called once per +connection and loops in case of a persistent connection +while PROCESS-REQUEST is called anew for each +request. +

+Like PROCESS-CONNECTION, this might be a good +place to introduce around methods which bind special variables or do +other interesting things. +

+

+The return value of this function is ignored. +

+
+
+
=20 Modified: trunk/thirdparty/hunchentoot/log.lisp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/thirdparty/hunchentoot/log.lisp 2009-02-18 19:58:57 UTC (rev 4280) +++ trunk/thirdparty/hunchentoot/log.lisp 2009-02-18 20:28:27 UTC (rev 4281) @@ -30,6 +30,11 @@ (in-package :hunchentoot) =20 (defmacro with-log-file ((stream-var pathname lock) &body body) + "Helper macro which executes BODY only if PATHNAME \(which is +evaluated) is not NIL. In this case, the file designated by PATHNAME +is opened for writing \(appending) and created if it doesn't exist. +STREAM-VAR is then bound to a flexi stream which can be used to write +characters to the file in UTF-8 format." (with-unique-names (binary-stream) (with-rebinding (pathname) `(when ,pathname @@ -77,7 +82,13 @@ =20 (defun log-message (log-level format-string &rest format-arguments) "Convenience function which calls the message logger of the current -acceptor \(if there is one) with the same arguments it accepts." +acceptor \(if there is one) with the same arguments it accepts. + +Returns NIL if there is no message logger or whatever the message +logger returns. + +This is the function which Hunchentoot itself uses to log errors it +catches during request processing." (when-let (message-logger (acceptor-message-logger *acceptor*)) (apply message-logger log-level format-string format-arguments))) =20 Modified: trunk/thirdparty/hunchentoot/request.lisp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/thirdparty/hunchentoot/request.lisp 2009-02-18 19:58:57 UTC (rev 42= 80) +++ trunk/thirdparty/hunchentoot/request.lisp 2009-02-18 20:28:27 UTC (rev 42= 81) @@ -99,10 +99,10 @@ (:documentation "This function is called by PROCESS-CONNECTION after the incoming headers have been read. It selects and calls a handler and sends the output of this handler to the client using START-OUTPUT. -It also sets up simple error handling for the actual request handler. -Note that PROCESS-CONNECTION is called once per connection and loops -in case of a persistent connection while PROCESS-REQUEST is called -anew for each request. +It also sets up simple error handling for the request handler. Note +that PROCESS-CONNECTION is called once per connection and loops in +case of a persistent connection while PROCESS-REQUEST is called anew +for each request. =20 Like PROCESS-CONNECTION, this might be a good place to introduce around methods which bind special variables or do other interesting Modified: trunk/thirdparty/hunchentoot/specials.lisp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/thirdparty/hunchentoot/specials.lisp 2009-02-18 19:58:57 UTC (rev 4= 280) +++ trunk/thirdparty/hunchentoot/specials.lisp 2009-02-18 20:28:27 UTC (rev 4= 281) @@ -194,19 +194,21 @@ purposes.") =20 (defvar *show-lisp-errors-p* nil - "Whether Lisp errors should be shown in HTML output.") + "Whether Lisp errors in request handlers should be shown in HTML output.") =20 (defvar *log-lisp-errors-p* t - "Whether Lisp errors should be logged.") + "Whether Lisp errors in request handlers should be logged.") =20 (defvar *log-lisp-warnings-p* t - "Whether Lisp warnings should be logged.") + "Whether Lisp warnings in request handlers should be logged.") =20 (defvar *lisp-errors-log-level* :error - "Log level for Lisp errors.") + "Log level for Lisp errors. Should be one of :ERROR \(the default), +:WARNING, or :INFO.") =20 (defvar *lisp-warnings-log-level* :warning - "Log level for Lisp warnings.") + "Log level for Lisp warnings. Should be one of :ERROR, :WARNING +\(the default), or :INFO.") =20 (defvar *message-log-pathname* nil "A designator for the pathname of the message log file used by the @@ -216,7 +218,7 @@ (defvar *access-log-pathname* nil "A designator for the pathname of the access log file used by the LOG-ACCESS-TO-FILE function. The initial value is NIL which means -that nothingq will be logged.") +that nothing will be logged.") =20 (defvar *message-log-lock* (make-lock "global-message-log-lock") "A global lock to prevent concurrent access to the log file --===============2027815849467171187==--