pvl.args: implement --log-file
authorTero Marttila <terom@paivola.fi>
Fri, 11 Jan 2013 22:40:51 +0200
changeset 86 5bd98d185c48
parent 85 d1c2dfc1a875
child 87 70edcd13a447
pvl.args: implement --log-file
pvl/args.py
--- a/pvl/args.py	Fri Jan 11 22:04:28 2013 +0200
+++ b/pvl/args.py	Fri Jan 11 22:40:51 2013 +0200
@@ -15,6 +15,7 @@
     general.add_option('-q', '--quiet',     dest='loglevel', action='store_const', const=logging.ERROR, help="Less output")
     general.add_option('-v', '--verbose',   dest='loglevel', action='store_const', const=logging.INFO,  help="More output")
     general.add_option('-D', '--debug',     dest='loglevel', action='store_const', const=logging.DEBUG, help="Even more output")
+    general.add_option('--log-file',                                                                    help="Log to file")
     general.add_option('--debug-module',    action='append', metavar='MODULE', 
             help="Enable logging for the given logger/module name")
 
@@ -40,8 +41,9 @@
     # configure
     logging.basicConfig(
         # XXX: log Class.__init__ as Class, not __init__?
-        format  = prefix + '%(name)-20s: %(levelname)5s %(funcName)s: %(message)s',
-        level   = options.loglevel,
+        format      = prefix + '%(name)-20s: %(levelname)5s %(funcName)s: %(message)s',
+        level       = options.loglevel,
+        filename    = options.log_file,
     )
 
     # enable debugging for specific targets