[Checkins] SVN: zc.zodbdgc/branches/dev/src/zc/zodbdgc/ Added command-line options to control logging and enabled logging when

Jim Fulton jim at zope.com
Tue May 19 10:56:31 EDT 2009


Log message for revision 100129:
  Added command-line options to control logging and enabled logging when
  no options are specified and when called from wrapper script.
  

Changed:
  U   zc.zodbdgc/branches/dev/src/zc/zodbdgc/README.test
  U   zc.zodbdgc/branches/dev/src/zc/zodbdgc/__init__.py

-=-
Modified: zc.zodbdgc/branches/dev/src/zc/zodbdgc/README.test
===================================================================
--- zc.zodbdgc/branches/dev/src/zc/zodbdgc/README.test	2009-05-19 13:40:55 UTC (rev 100128)
+++ zc.zodbdgc/branches/dev/src/zc/zodbdgc/README.test	2009-05-19 14:56:31 UTC (rev 100129)
@@ -257,6 +257,8 @@
     options:
       -h, --help            show this help message and exit
       -d DAYS, --days=DAYS  Number of trailing days to treat as non-garbage
+      -l LEVEL, --log-level=LEVEL
+                            The logging level. The default is WARNING.
 
     >>> bad2 = zc.zodbdgc.gc_command(['-d2', 'config', 'config2'])
     Ignoring index for 1.fs

Modified: zc.zodbdgc/branches/dev/src/zc/zodbdgc/__init__.py
===================================================================
--- zc.zodbdgc/branches/dev/src/zc/zodbdgc/__init__.py	2009-05-19 13:40:55 UTC (rev 100128)
+++ zc.zodbdgc/branches/dev/src/zc/zodbdgc/__init__.py	2009-05-19 14:56:31 UTC (rev 100129)
@@ -237,16 +237,29 @@
 def gc_command(args=None):
     if args is None:
         args = sys.argv[1:]
+        level = logging.WARNING
+    else:
+        level = None
+
     parser = optparse.OptionParser("usage: %prog [options] config1 [config2]")
     parser.add_option(
         '-d', '--days', dest='days', type='int', default=1,
         help='Number of trailing days to treat as non-garbage')
+    parser.add_option(
+        '-l', '--log-level', dest='level',
+        help='The logging level. The default is WARNING.')
 
     options, args = parser.parse_args(args)
 
     if not args or len(args) > 2:
         parser.parse_args(['-h'])
 
+    if options.level:
+        level = options.level
+
+    if level:
+        logging.basicConfig(level=getattr(logging, level))
+
     return gc(args[0], options.days, *args[1:])
 
 def check(config):
@@ -288,7 +301,10 @@
 def check_command(args=None):
     if args is None:
         args = sys.argv[1:]
+        logging.basicConfig(level=logging.WARNING)
+
     parser = optparse.OptionParser("usage: %prog [options] config")
+
     options, args = parser.parse_args(args)
 
     if not args or len(args) > 1:



More information about the Checkins mailing list