[Webkit-unassigned] [Bug 35194] New: run-chromium-webkit-tests: should log to non-root loggers

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sat Feb 20 07:49:49 PST 2010


https://bugs.webkit.org/show_bug.cgi?id=35194

           Summary: run-chromium-webkit-tests: should log to non-root
                    loggers
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: All
        OS/Version: Mac OS X 10.5
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: Tools / Tests
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: cjerdonek at webkit.org
                CC: eric at webkit.org, abarth at webkit.org,
                    levin at chromium.org, hamaji at chromium.org


Currently, run-chromium-webkit-tests logs directly to the root logger.  For
example--

    def __del__(self):
        logging.debug("flushing stdout")
        sys.stdout.flush()
        logging.debug("flushing stderr")
        sys.stderr.flush()

This means that logging for run-chromium-webkit-tests can't be configured
independently of other modules (i.e. without also changing the logging behavior
of other modules).

A better practice for larger bodies of code is for each module (or at least
each application) to log to its own logger.  See this documentation, for
example:

"The logging module supports a hierarchy of loggers with different names. An
easy way to tell where a specific log message comes from is to use a separate
logger object for each of your modules. Each new logger “inherits” the
configuration of its parent, and log messages sent to a logger include the name
of that logger..."

(from http://docs.python.org/library/logging.html#simple-examples ) 

For example, the autoinstall module does this by writing the following towards
the beginning--

_logger = logging.getLogger(__name__)

This automatically gives the logger the hierarchical name of its module, e.g.

webkitpy.autoinstall: INFO     Getting
'http://pypi.python.org/packages/source/C/ClientForm/ClientForm-0.2.10.zip'
from cache.

With this change, the code at the top would look something like this instead--

    def __del__(self):
        log.debug("flushing stdout")
        sys.stdout.flush()
        log.debug("flushing stderr")
        sys.stderr.flush()

(I personally prefer log.debug, etc. over logger.debug, etc. since the
construct will be used frequently, and it is shorter to read and type.)

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list