[svn] Add options to tweak the logging level to taste. trunk

Tue, 19 Dec 2006 19:27:14 -0500

author
brett
date
Tue, 19 Dec 2006 19:27:14 -0500
branch
trunk
changeset 13
0a3ef1b9f6d4
parent 12
5d202467c589
child 14
6f9e1bb59719

[svn] Add options to tweak the logging level to taste.

TODO file | annotate | diff | comparison | revisions
scripts/x file | annotate | diff | comparison | revisions
--- a/TODO	Tue Dec 19 19:13:29 2006 -0500
+++ b/TODO	Tue Dec 19 19:27:14 2006 -0500
@@ -1,14 +1,14 @@
 Things which I have a use case/anti-use case for:
+* Avoid overwriting directories.
 * Decompress non-archive files.
-* Figure out what to do about warnings in the Handlers.
+* Better error messages (file doesn't exist, isn't readable, etc.)
+* Interactivity: ask about overwriting, recursing, etc.
 
 Things that are generally good:
 * Better tests.
 * Better error messages.
 
 Things I think might be good but can't prove:
-* Interactivity ("This archive contains other archive files.  Would you
-  like to extract them as well?")
 * Consider having options about whether or not to make sane directories,
   have tarbomb protection, etc.
 * Use zipfile instead of the zip commands.
--- a/scripts/x	Tue Dec 19 19:13:29 2006 -0500
+++ b/scripts/x	Tue Dec 19 19:27:14 2006 -0500
@@ -332,6 +332,12 @@
         parser.add_option('-r', '--recursive', dest='recursive',
                           action='store_true', default=False,
                           help='extract archives contained in the ones listed')
+        parser.add_option('-q', '--quiet', dest='quiet',
+                          action='count', default=3,
+                          help='suppress warning/error messages')
+        parser.add_option('-v', '--verbose', dest='verbose',
+                          action='count', default=0,
+                          help='be verbose/print debugging information')
         self.options, filenames = parser.parse_args(arguments)
         if not filenames:
             parser.error("you did not list any archives")
@@ -340,8 +346,8 @@
     def setup_logger(self):
         self.logger = logging.getLogger('x-log')
         handler = logging.StreamHandler()
-        # Switch here.
-        handler.setLevel(logging.WARNING)
+        # WARNING is the default.
+        handler.setLevel(10 * (self.options.quiet - self.options.verbose))
         formatter = logging.Formatter("x: %(levelname)s: %(message)s")
         handler.setFormatter(formatter)
         self.logger.addHandler(handler)

mercurial