From fa76abbb326ca41f1997ee80d6a548f30d88a7c7 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Fri, 29 Mar 2013 12:13:06 +0100 Subject: [PATCH] Use loggging everywhere. --- bin/swsync | 1 + swsync/accounts.py | 11 ++++++----- swsync/containers.py | 4 +++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/bin/swsync b/bin/swsync index f1bceb2..4b4a7dc 100755 --- a/bin/swsync +++ b/bin/swsync @@ -59,6 +59,7 @@ class Main(object): except(ConfigurationError): parser.print_help() sys.exit(1) + self.set_logging() #beurk swsync.utils.CONFIG = conf diff --git a/swsync/accounts.py b/swsync/accounts.py index 32f330c..581b37d 100644 --- a/swsync/accounts.py +++ b/swsync/accounts.py @@ -16,6 +16,7 @@ # under the License. import time import datetime +import logging import swiftclient import dateutil.relativedelta @@ -62,7 +63,7 @@ class Accounts(object): full_listing=True)) for container in orig_containers: - print container + logging.info("Syncronizing %s: %s", container['name'], container) dt1 = datetime.datetime.fromtimestamp(time.time()) self.container_cls.sync(orig_storage_cnx, orig_storage_url, @@ -74,10 +75,10 @@ class Accounts(object): dt2 = datetime.datetime.fromtimestamp(time.time()) rd = dateutil.relativedelta.relativedelta(dt2, dt1) #TODO(chmou): use logging - print "%d hours, %d minutes and %d seconds" % (rd.hours, - rd.minutes, - rd.seconds) - print + logging.info("%s done: %d hours, %d minutes and %d seconds", + container['name'], + rd.hours, + rd.minutes, rd.seconds) def process(self): """Process all keystone accounts to sync.""" diff --git a/swsync/containers.py b/swsync/containers.py index 89ea0df..46a7466 100644 --- a/swsync/containers.py +++ b/swsync/containers.py @@ -14,6 +14,8 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +import logging + import swiftclient import eventlet @@ -63,7 +65,7 @@ class Containers(object): pool = eventlet.GreenPool(size=self.max_gthreads) pile = eventlet.GreenPile(pool) for obj in diff: - print obj + logging.info("sending: %s ts:%s", obj[1], obj[0]) pile.spawn(self.objects_cls, orig_storage_url, orig_token,