Author: Alexander Zangerl  <az@debian.org>
Subject: fix logging in paramiko backend

diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' duplicity-0.6.20~/duplicity/backends/_ssh_paramiko.py duplicity-0.6.20/duplicity/backends/_ssh_paramiko.py
--- duplicity-0.6.20~/duplicity/backends/_ssh_paramiko.py	2012-10-28 22:23:52.000000000 +1000
+++ duplicity-0.6.20/duplicity/backends/_ssh_paramiko.py	2012-12-30 17:19:29.526043360 +1000
@@ -30,6 +30,7 @@
 import sys
 import time
 import getpass
+import logging
 from binascii import hexlify
 
 import duplicity.backend
@@ -104,6 +105,30 @@
 
         self.client = paramiko.SSHClient()
         self.client.set_missing_host_key_policy(AgreedAddPolicy())
+
+        # paramiko uses logging with the normal python severity levels,
+        # but duplicity uses both custom levels and inverted logic...*sigh*
+        self.client.set_log_channel("sshbackend")
+        ours=paramiko.util.get_logger("sshbackend")
+        dest=logging.StreamHandler(sys.stderr)
+        dest.setFormatter(logging.Formatter('ssh: %(message)s'))
+        ours.addHandler(dest)
+
+        # ..and the duplicity levels are neither linear, 
+        # nor are the names compatible with python logging, eg. 'NOTICE'...WAAAAAH!
+        plevel=logging.getLogger("duplicity").getEffectiveLevel()
+        if plevel <= 1:
+            wanted=logging.DEBUG
+        elif plevel <= 5:
+            wanted=logging.INFO
+        elif plevel <= 7:
+            wanted=logging.WARNING
+        elif plevel <= 9:
+            wanted=logging.ERROR
+        else:
+            wanted=logging.CRITICAL
+        ours.setLevel(wanted)
+
         # load known_hosts files
         # paramiko is very picky wrt format and bails out on any problem...
         try:
