[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r1297676 - /subversion/trunk/subversion/tests/cmdline/svntest/main.py

From: Hyrum K Wright <hyrum.wright_at_wandisco.com>
Date: Tue, 6 Mar 2012 15:08:16 -0600

On Tue, Mar 6, 2012 at 3:02 PM, Greg Stein <gstein_at_gmail.com> wrote:
> On Tue, Mar 6, 2012 at 15:58, Hyrum K Wright <hyrum.wright_at_wandisco.com> wrote:
>> On Tue, Mar 6, 2012 at 2:42 PM, Greg Stein <gstein_at_gmail.com> wrote:
>>> You may as well use the default logger. That way, every module can
>>> just: import logging ; logging.info('whatever: %s %s', foo, bar)
>> I thought about that, but figured using the custom logger would give
>> us more flexibility.  Separate test suites could use separate loggers
>> when run in parallel, for instance, and they wouldn't interleave each.
>>  By establishing the habit of using a named logger, rather than the
>> default one, it means we can just change the logger reference, instead
>> of go back and rewrite everything to use a custom logger later.
>> This first pass is to just get as much as possible using the logging
>> framework, and then we can go back and worry about such things.  I
>> just don't want us to prematurely optimize. :)
> Euh... that's not premature optimization. That is keeping things
> *simple* unless and until circumstances dictate that we need more
> complexity. You haven't demonstrated that at all yet.
> And as long as you keep doing a per-module logger, then each and every
> one of those loggers will need to be configured. Add a stream handler.
> Add a formatter. Adjust their loglevel based on the verbose flag.
> etc-f'in-etc.
> By sticking to the root logger, the main.py can get it configured
> properly and all modules can use it without concern. As it stands,
> per-module loggers absolutely increases complexity with zero benefit.

I understand your eloquently-put point. I've no objection to using the root
logger, but I'd like to refer to it through a named variable, rather
than using the global variable implicit in the "logging.debug()"

>>> You may want to change most of the calls to logging.FOO rather than
>>> logger.FOO for consistency with other modules that will use the
>>> logging framework.
>>> I would also recommend creating a Formatter and attaching it to that
>>> StreamHandler:
>>>    formatter = logging.Formatter('%(asctime)s [%(levelname)s] %(message)s',
>>>                                  '%Y-%m-%d %H:%M:%S')
>>>    handler.setFormatter(formatter)
>>> that will give us a timestamp for each line.
>> Future Work.  A valuable suggestion, but right now I'm focused on
>> getting the logging infrastructure in place, so we can make this kind
>> of changes on a system-wide basis.
> It can only be done (easily) on a system-wide basis if you use the
> root logger :-)

Or have a logger constructor/fetcher method. :)


uberSVN: Apache Subversion Made Easy
Received on 2012-03-06 22:08:48 CET

This is an archived mail posted to the Subversion Dev mailing list.