[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: Greg Stein <gstein_at_gmail.com>
Date: Tue, 6 Mar 2012 15:42:48 -0500

On Tue, Mar 6, 2012 at 15:18, <hwright_at_apache.org> wrote:
>...
> +++ subversion/trunk/subversion/tests/cmdline/svntest/main.py Tue Mar  6 20:18:16 2012
>...
> @@ -78,6 +79,10 @@ SVN_VER_MINOR = 8
>
>  default_num_threads = 5
>
> +# Set up logging
> +logger = logging.getLogger(__name__)

You may as well use the default logger. That way, every module can
just: import logging ; logging.info('whatever: %s %s', foo, bar)

>...
> @@ -1473,6 +1469,9 @@ def create_default_options():
>
>  def _create_parser():
>   """Return a parser for our test suite."""
> +  def set_log_debug(option, opt, value, parser):
> +    logger.setLevel(logging.DEBUG)

axe this, see below:

> +
>   # set up the parser
>   _default_http_library = 'serf'
>   usage = 'usage: %prog [options] [<test> ...]'
> @@ -1481,7 +1480,8 @@ def _create_parser():
>                     help='Print test doc strings instead of running them')
>   parser.add_option('--milestone-filter', action='store', dest='milestone_filter',
>                     help='Limit --list to those with target milestone specified')
> -  parser.add_option('-v', '--verbose', action='store_true', dest='verbose',
> +  parser.add_option('-v', '--verbose', action='callback',
> +                    callback=set_log_debug,
>                     help='Print binary command-lines (not with --quiet)')

callback=logger.setLevel, callback_args=(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.

Cheers,
-g
Received on 2012-03-06 21:43:20 CET

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