Opened 9 years ago

Closed 9 years ago

#25775 closed Cleanup/optimization (duplicate)

Method log_message in server.py uses sys.stderr.write, not logging

Reported by: Aleksey @soar Smyrnov Owned by: nobody
Component: HTTP handling Version: 1.8
Severity: Normal Keywords: log, logging, stdout
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I try to capture all log output of my Django-based project, but logged requests like:

[19/Nov/2015 12:30:12] "GET / HTTP/1.1" 200 12898
[19/Nov/2015 12:37:32] "GET /favicon.ico HTTP/1.1" 302 0

can't be catched, reformatted, etc. I found line, where this log caused:

    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
        message to be logged.  If the format string contains
        any % escapes requiring parameters, they should be
        specified as subsequent arguments (it's just like
        printf!).

        The client ip and current date/time are prefixed to
        every message.

        """

        sys.stderr.write("%s - - [%s] %s\n" %
                         (self.client_address[0],
                          self.log_date_time_string(),
                          format%args))

So, why you use sys.stderr.write(), not logging.debug()/info()/warn()/etc?

Change History (1)

comment:1 by Tim Graham, 9 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #25684

Note: See TracTickets for help on using tickets.
Back to Top