bin: fix logging progname prefix
authorTero Marttila <terom@paivola.fi>
Tue, 19 Jun 2012 10:26:15 +0300
changeset 62 86ba7b12a7c9
parent 61 4fdf70cbc9b0
child 63 4293baf688b1
bin: fix logging progname prefix
bin/pvl.backup-rsync
bin/pvl.backup-snapshot
--- a/bin/pvl.backup-rsync	Tue Jun 19 10:24:20 2012 +0300
+++ b/bin/pvl.backup-rsync	Tue Jun 19 10:26:15 2012 +0300
@@ -4,9 +4,9 @@
     SSH authorized_keys command="..." wrapper for rsync.
 
     Testing goes something like:
-        sudo PYTHONPATH=. ./bin/pvlbackup-rsync-wrapper --command 'rsync --server --sender -ax . lvm:asdf:test' -vD
+        sudo PYTHONPATH=. ./bin/pvl.backup-rsync --command 'rsync --server --sender -ax . lvm:asdf:test' -vD
 
-        sudo sh -c "PYTHONPATH=. rsync -e './bin/pvlbackup-rsync-wrapper --debug -C --' -ax testing:lvm:asdf:test test/tmp"
+        sudo sh -c "PYTHONPATH=. rsync -e './bin/pvl.backup-rsync --debug -C --' -ax testing:lvm:asdf:test test/tmp"
 """
 
 from pvl.backup import __version__
@@ -19,7 +19,7 @@
 import os
 import logging
 
-log = logging.getLogger()
+log = logging.getLogger('main')
 
 def parse_options (argv) :
     """
@@ -69,6 +69,9 @@
     parser.add_option('--snapshot-wait', metavar='SECONDS', default=lvm.LVM_SNAPSHOT_WAIT, type='float',
             help="wait for snapshot to settle after unmounting")
 
+    parser.add_option('--snapshot-retry', metavar='RETRY', default=lvm.LVM_SNAPSHOT_RETRY, type='int',
+            help="retry snapshot removal by given iterations")
+
     # defaults
     parser.set_defaults(
         debug_for   = [],
@@ -80,7 +83,7 @@
 
     # configure
     logging.basicConfig(
-        format  = '%(levelname)6s %(name)s : %(funcName)s : %(message)s',
+        format  = argv[0] + ': %(levelname)6s %(name)s : %(funcName)s : %(message)s',
         level   = options.loglevel,
     )
 
@@ -118,7 +121,7 @@
         # parse the source path as given by the client, may be a real path or pseudo-path
         source = rsync.parse_source(path,
                 restrict_path       = options.restrict_path,
-                lvm_opts            = dict(size = options.snapshot_size, wait = options.snapshot_wait),
+                lvm_opts            = dict(size=options.snapshot_size, wait=options.snapshot_wait, retry=options.snapshot_retry),
             )
 
     except RSyncCommandFormatError, e:
--- a/bin/pvl.backup-snapshot	Tue Jun 19 10:24:20 2012 +0300
+++ b/bin/pvl.backup-snapshot	Tue Jun 19 10:26:15 2012 +0300
@@ -19,7 +19,7 @@
 import datetime
 import logging
 
-log = logging.getLogger()
+log = logging.getLogger('main')
 
 # command-line options, global state
 options = None
@@ -105,7 +105,7 @@
 
     # configure
     logging.basicConfig(
-        format  = '%(processName)s: %(name)s: %(levelname)s %(funcName)s : %(message)s',
+        format  = argv[0] + ': %(name)s: %(levelname)s %(funcName)s : %(message)s',
         level   = options.loglevel,
     )