# HG changeset patch # Parent 0a47d0cd92e29731059972f5985cc7d073754adb diff --git a/Doc/library/http.server.rst b/Doc/library/http.server.rst --- a/Doc/library/http.server.rst +++ b/Doc/library/http.server.rst @@ -182,24 +182,24 @@ of which this module provides three diff .. method:: log_request(code='-', size='-') Logs an accepted (successful) request. *code* should specify the numeric HTTP code associated with the response. If a size of the response is available, then it should be passed as the *size* parameter. .. method:: log_error(...) - Logs an error when a request cannot be fulfilled. By default, it passes - the message to :meth:`log_message`, so it takes the same arguments - (*format* and additional values). + Logs an error message to ``sys.stderr`` when a request cannot be + fulfilled. By default, it passes the message to :meth:`log_message`, + so it takes the same arguments (*format* and additional values). .. method:: log_message(format, ...) - Logs an arbitrary message to ``sys.stderr``. This is typically overridden + Logs an arbitrary message to ``sys.stdout``. This is typically overridden to create custom error logging mechanisms. The *format* argument is a standard printf-style format string, where the additional arguments to :meth:`log_message` are applied as inputs to the formatting. The client address and current date and time are prefixed to every message logged. .. method:: version_string() Returns the server software's version string. This is a combination of the diff --git a/Lib/http/server.py b/Lib/http/server.py --- a/Lib/http/server.py +++ b/Lib/http/server.py @@ -445,17 +445,20 @@ class BaseHTTPRequestHandler(socketserve default it passes the message on to log_message(). Arguments are the same as for log_message(). XXX This should go to the separate error log. """ - self.log_message(format, *args) + sys.stderr.write("%s - - [%s] %s\n" % + (self.address_string(), + self.log_date_time_string(), + format%args)) def log_message(self, format, *args): """Log an arbitrary message. This is used by all other logging functions. Override it if you have specific logging wishes. The first argument, FORMAT, is a format string for the @@ -464,17 +467,17 @@ class BaseHTTPRequestHandler(socketserve specified as subsequent arguments (it's just like printf!). The client host and current date/time are prefixed to every message. """ - sys.stderr.write("%s - - [%s] %s\n" % + sys.stdout.write("%s - - [%s] %s\n" % (self.address_string(), self.log_date_time_string(), format%args)) def version_string(self): """Return the server software version string.""" return self.server_version + ' ' + self.sys_version