Use loggging everywhere.

This commit is contained in:
Chmouel Boudjnah 2013-03-29 12:13:06 +01:00
parent 44ef61d544
commit fa76abbb32
3 changed files with 10 additions and 6 deletions

View File

@ -59,6 +59,7 @@ class Main(object):
except(ConfigurationError):
parser.print_help()
sys.exit(1)
self.set_logging()
#beurk
swsync.utils.CONFIG = conf

View File

@ -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."""

View File

@ -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,