SVN: r25351 - in trunk/quixote: . doc

Neil Schemenauer <nascheme-fVcApmY9cLvQ3/1i3zOLAti2O/[email protected]> Thu, 14 Oct 2004 15:06:58 -0400
Newsgroups gmane.comp.web.quixote.cvs
Message-ID <[email protected]>
Author: nascheme
Date: 2004-10-14 15:06:43 -0400 (Thu, 14 Oct 2004)
New Revision: 25351

Modified:
   trunk/quixote/config.py
   trunk/quixote/doc/demo.txt
   trunk/quixote/doc/programming.txt
   trunk/quixote/publish.py
Log:
Remove DEBUG_LOG configuration option.  Having debug output go to
the error log seems to be preferable.


Modified: trunk/quixote/config.py
===================================================================
--- trunk/quixote/config.py	2004-10-14 18:16:40 UTC (rev 25350)
+++ trunk/quixote/config.py	2004-10-14 19:06:43 UTC (rev 25351)
@@ -37,16 +37,11 @@
 ACCESS_LOG = None
 #ACCESS_LOG = "/www/log/quixote-access.log"
 
-# Filename for logging error messages; if None, everything will be sent
-# to standard error, so it should wind up in the Web server's error log
-# file.
+# Filename for logging error messages and debugging output; if None,
+# everything will be sent to standard error (normally ending up in the
+# Web server's error log file.
 ERROR_LOG = None
 
-# Filename for logging debugging output; if None then debugging output
-# goes to the error log. (Anything that application code prints to
-# stdout is debug output.)
-DEBUG_LOG = None
-
 # Controls what's done when uncaught exceptions occur.  If set to
 # 'plain', the traceback will be returned to the browser in addition
 # to being logged, If set to 'html' and the cgitb module is installed,
@@ -177,7 +172,6 @@
     config_vars = [
         'error_email',
         'access_log',
-        'debug_log',
         'display_exceptions',
         'secure_errors',
         'error_log',

Modified: trunk/quixote/doc/demo.txt
===================================================================
--- trunk/quixote/doc/demo.txt	2004-10-14 18:16:40 UTC (rev 25350)
+++ trunk/quixote/doc/demo.txt	2004-10-14 19:06:43 UTC (rev 25351)
@@ -186,11 +186,9 @@
 application, log files are essential for debugging Quixote applications.
 
 Assuming that your web server's error log is in /www/log/error_log, and
-that you haven't changed the DEBUG_LOG and ERROR_LOG settings in
-demo.conf::
+that you haven't changed the ERROR_LOG setting in demo.conf::
 
     $ tail -f /www/log/error_log & \
-      tail -f /tmp/quixote-demo-debug.log & \
       tail -f /tmp/quixote-demo-error.log 
 
 (Note that recent versions of GNU tail let you tail multiple files with
@@ -200,7 +198,7 @@
 ----------------------
 
 Reload the top of the demo, presumably ``http://localhost/qdemo/``.  You
-should see "debug message from the index page" in the debug log file.
+should see "debug message from the index page" in the quixote error log.
 
 Where is this message coming from?  To find out, we need to delve into
 the source code for the demo.  Load up demo/__init__.py and let's take a
@@ -255,8 +253,7 @@
   namespace; if it exists, it will be used
 
 * anything your application prints to standard output goes to
-  Quixote's debug log.  (If you didn't specify a debug log in
-  your config file, debug messages are discarded.)
+  Quixote's error log.
 
 
 Lesson 2: a link to a simple document

Modified: trunk/quixote/doc/programming.txt
===================================================================
--- trunk/quixote/doc/programming.txt	2004-10-14 18:16:40 UTC (rev 25350)
+++ trunk/quixote/doc/programming.txt	2004-10-14 19:06:43 UTC (rev 25351)
@@ -143,7 +143,6 @@
 it's easy to set config variables::
 
     ACCESS_LOG = "/www/log/access/books.log" 
-    DEBUG_LOG = "/www/log/books-debug.log"
     ERROR_LOG = "/www/log/books-error.log"
 
 You can also execute arbitrary Python code to figure out what the
@@ -171,12 +170,11 @@
 Logging
 -------
 
-Every Quixote application can have up to three log files, each of
+Every Quixote application can have two different log files, each of
 which is selected by a different configuration variable:
 
 * access log (``ACCESS_LOG``)
 * error log (``ERROR_LOG``)
-* debug log (``DEBUG_LOG``)
 
 If you want logging to work, you must call ``setup_logs()`` on your
 Publisher object after creating it and reading any application-specific
@@ -209,22 +207,20 @@
 If no access log is configured (ie., ``ACCESS_LOG`` is ``None``), then
 Quixote will not do any access logging.
 
-The error log is used for two purposes:
+The error log is used for three purposes:
 
-* all application output to standard error (``sys.stderr``) goes to
+* application output to ``sys.stdout`` and ``sys.stderr`` goes to
   Quixote's error log
-* all application tracebacks will be written to Quixote's error log
+* application tracebacks will be written to Quixote's error log
 
-If no error log is configured (with ``ERROR_LOG``), then both types of
-messages will be written to the stderr supplied to Quixote for this
-request by your web server.  At least for CGI/FastCGI scripts under
-Apache, this winds up in Apache's error log.
+If no error log is configured (with ``ERROR_LOG``), then all output is
+redirected to the stderr supplied to Quixote for this request by your
+web server.  At least for CGI/FastCGI scripts under Apache, this winds
+up in Apache's error log.
 
-The debug log is where any application output to stdout goes.  Thus, you
-can just sprinkle ``print`` statements into your application for
-debugging; if you have configured a debug log, those print statements
-will wind up there.  If you don't configure a debug log, they go to the
-bit bucket (``/dev/null`` on Unix, ``NUL`` on Windows).
+Having stdout redirected to the error log is useful for debugging.  You
+can just sprinkle ``print`` statements into your application and the
+output will wind up in the error log.
 
 
 Application code

Modified: trunk/quixote/publish.py
===================================================================
--- trunk/quixote/publish.py	2004-10-14 18:16:40 UTC (rev 25350)
+++ trunk/quixote/publish.py	2004-10-14 19:06:43 UTC (rev 25351)
@@ -155,6 +155,8 @@
         the debug log.
         """
 
+        sys.stdout = sys.stderr
+
         if self.config.access_log is not None:
             try:
                 self.access_log = open(self.config.access_log, 'a', 1)
@@ -165,21 +167,12 @@
         if self.config.error_log is not None:
             try:
                 self.error_log = open(self.config.error_log, 'a', 1)
-                sys.stderr = self.error_log
+                sys.stdout = sys.stderr = self.error_log
             except IOError, exc:
                 # leave self.error_log as it was, most likely sys.stderr
                 sys.stderr.write("error opening error log %s: %s\n"
                                  % (`self.config.error_log`, exc.strerror))
-
-        if self.config.debug_log is not None:
-            try:
-                debug_log = open(self.config.debug_log, 'a', 1)
-                sys.stdout = debug_log
-            except IOError, exc:
-                sys.stderr.write("error opening debug log %s: %s\n"
-                                 % (`self.config.debug_log`, exc.strerror))
-
-
+        
     def shutdown_logs(self):
         """
         Close log files and restore sys.stdout and sys.stderr to their
@@ -187,8 +180,6 @@
         """
         if sys.stdout is sys.__stdout__:
             raise RuntimeError, "'setup_logs()' never called"
-        if sys.stdout is not sys.stderr:
-            sys.stdout.close()
         sys.stdout = sys.__stdout__
         self.access_log.close()
         if self.error_log is not sys.__stderr__:
@@ -203,8 +194,6 @@
                                   time.localtime(time.time()))
         self.error_log.write("[%s] %s\n" % (timestamp, msg))
 
-    debug = log # backwards compatibility
-
     def parse_request(self, request):
         """Parse the request information waiting in 'request'.
         """