Improve logging.

This commit is contained in:
Tomeu Vizoso 2007-05-16 17:01:59 +02:00
parent 79fdfc5fb7
commit 7314d5a8c8

View File

@ -34,32 +34,13 @@ except Exception, e:
_data_store = None
logging.error(e)
def get_contents(filename):
if not filename:
return ''
f = open(filename, "r")
try:
contents = f.read()
finally:
f.close()
return contents
def create(properties, filename):
logging.debug('dbus_helpers.create: %s, %s' % (properties, filename))
try:
logging.debug(get_contents(filename))
except UnicodeDecodeError:
pass
object_id = _data_store.create(dbus.Dictionary(properties), filename)
logging.debug('dbus_helpers.create: ' + object_id)
return object_id
def update(uid, properties, filename, reply_handler=None, error_handler=None):
logging.debug('dbus_helpers.update: %s, %s, %s' % (uid, properties, filename))
try:
logging.debug(get_contents(filename))
except UnicodeDecodeError:
pass
logging.debug('dbus_helpers.update')
if reply_handler and error_handler:
_data_store.update(uid, dbus.Dictionary(properties), filename,
reply_handler=reply_handler,
@ -68,20 +49,16 @@ def update(uid, properties, filename, reply_handler=None, error_handler=None):
_data_store.update(uid, dbus.Dictionary(properties), filename)
def get_properties(uid):
props = _data_store.get_properties(uid)
logging.debug('dbus_helpers.get_properties: %s, %s' % (uid, props))
return props
logging.debug('dbus_helpers.get_properties: %s' % uid)
return _data_store.get_properties(uid)
def get_filename(uid):
filename = _data_store.get_filename(uid)
logging.debug('dbus_helpers.get_filename: %s, %s' % (uid, filename))
try:
logging.debug(get_contents(filename))
except UnicodeDecodeError:
pass
return filename
def find(query, reply_handler, error_handler):
logging.debug('dbus_helpers.find')
if reply_handler and error_handler:
return _data_store.find(query, reply_handler=reply_handler,
error_handler=error_handler)