[Python-Dev] distutils & stderr (original) (raw)

M.-A. Lemburg mal@lemburg.com
Fri, 01 Feb 2002 12:58:33 +0100


Michael Hudson wrote:

Greg Ward <gward@python.net> writes: > On 31 January 2002, Jeremy Hylton said: > > I started a thread on similar issues on the distutils-sig mailing list > > a week or two ago. There's agreement that output is a problem. > > The amount of output, or the binary nature of control (total silence > vs. total verbosity)? I knew that was a minor problem when I wrote that > code initially, but had bigger fish to fry. I'm thinking that verbose should range from about -2 (no output at all, even from commands if we can supress it) to about 2 (stupid amounts of output) with the default being 0, where we take our guide from what make outputs by default. -v and -q would then be additive on the command line, so python setup.py -q -v -v -q -q would be an odd way of specifying "verbose==-1".

That looks like line noise :-)

> FWIW, my current thinking is that code that wants to be chatty should do > something like this: > > log(1, "installing foo.bar package") > ... > log(2, "copying foo/bar/baz.py to /usr/local/lib/python2.1/site-packages/foo/bar") > > The first number is the logging threshold, compared against a global > verbosity level.

This sounds good.

Hmm, that's very close to what I have implemented in mx.Log (see the egenix-mx-base package).

> In a strongly OO system like the Distutils, that should probably be > spelled > > log(N, msg) > > where the logging threshold is carried around in each object (or in some > global object). > > This shouldn't be too hard to bolt onto the existing code -- ISTR that > the verbose flag is readily available to every object in the system; > just change it from a boolean to an integer and ensure that every log > message goes through self.log(). > > Oh wait: most of the low-level worker code in the Distutils falls > outside the main class hierarchy, so the verbose flag isn't quite so > readily available; it gets passed in to a heck of a lot of functions. > Crap.

There are a lot of calls in disutils that go func(...,...,verbose=self.verbose, dryrun=self.dryrun); Would it really be so bad to have a global "verbose" variable in, say, core? (same for dryrun, too). Of course, what I would like is CL-style special variables, but ne'er mind that...

FYI, I usually use a package/module scope global logging object for this kind of thing (rather than a function which then looks somewhere for the debug level). Works great.

-- Marc-Andre Lemburg CEO eGenix.com Software GmbH


Company & Consulting: http://www.egenix.com/ Python Software: http://www.egenix.com/files/python/